When we try to access password protected buckets just by getting in to cbq in Couchbase version 4.0, it shows 10000 error saying “Authorization Failed Keyspace data”, we need to provide cbauth to get in to cbq to access these buckets. Follow below to access password protected bucket:

cd /opt/couchbase/bin (this may change based on installation platform and preferences)

and then

./cbq -engine=”http://<bucket_name&gt;:<bucket_password>@localhost:8093/“
once you are in cbq, run below command to make sure you can access all buckets:
select * from system:keyspaces;


Posted by: bgopi | May 6, 2016

ElasticSearch using Java

Here is how to access ElasticSearch cluster from a java program:

public class TestConnectES{

public void init(){

Settings settings = Settings.settingsBuilder()
.put(“client.transport.sniff”, true)
.put(“cluster.name”, “<your_cluster_name_here>”).build();

client = TransportClient.builder().settings(settings).build()
.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(“”), 9300))
.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(“”), 9300));


public void tearDown(){
* @param args
public static void main(String[] args) {
TestConnectES tc = new TestConnectES();
try {
} catch (UnknownHostException e) {



public void search(){

SearchRequestBuilder srb = client.prepareSearch(“<your_index_name_here>”);
String userQuery=”corporation”;
QueryBuilder qb = QueryBuilders.queryStringQuery(“_all:”+userQuery);//.defaultOperator(Operator.AND)
System.out.println(“Q: “+qb.toString());

SearchResponse searchResponse = srb.execute().actionGet();
SearchHit[] hits = searchResponse.getHits().getHits();

System.out.println(“Total hits: “+searchResponse.getHits().totalHits());
int showResults = hits.length > 10 ? 10:hits.length;

for(int i=0;i<showResults;i++){
System.out.println(“score: “+hits[i].getScore());
System.out.println(“source: “+hits[i].getSourceAsString());



If you have a base 64 value as element id and if you try jQuery selector, jQuery throws Syntax error, unrecognized expression error. you can not select using this type of values jQuery throws error, what you can do is get the element compare its id with value using if condition.

This is just an example:

var cbObjId=this.id;

//do something here



Posted by: bgopi | July 31, 2015

Im a friend of eclipse

friend of eclipse

When  you are using Eclipse Juno and when you try to add new perforce connection, you may get this error.

It can be fixed in two ways.

I. install Eclipse Luna and try adding connection

II. you dont want to install new eclipse,

1. run p4 trust command.

you need to install perforce for this, make sure executable permission on p4 and then run below command. If you are using linux, run this command from terminal where you are running eclipse. reopen eclipse after executing this command.

example: $>p4 trust -f

if you see this error: Connect to server failed; check $P4PORT, you need to specify P4PORT as mentioned below

$>export P4PORT=ssl:<your_comapny_perforce_host>:<port>

eg., export P4PORT=ssl:perforce.mycompany.com:3666

restart your eclipse, this should solve your problem, if not follow below method.

This could happen because of JCE jars you are using may not have unlimited trust, you may need to download unlimited trust jce jars and place them in the JRE location as mentioned below.

a. open Winodw>Preferences>Java>Installed JREs, make sure which JRE you are using (one which has check mark), take note of that location.

b. go to that location, example /usr/java/jdk1.7/jre/lib/security folder

c. place local_policy.jar and US_export_policy.jar found in the zip downloaded from here: http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html

d. restart eclipse

Now, add new connection, you should be able to add it.

Posted by: bgopi | November 7, 2014

Reading properties from xml file using gradle

Here is how to read properties defined in xml file and store them in ext scope so that you can access in your gradle build script later.

file: build.gradle

task parseXml() {
def parsedPropXml = (new XmlParser()).parse(‘properties.xml’)
parsedPropXml.property.each{ prop ->
project.ext.set(prop.@name, prop.@value)
println “<<print props>>”
project.ext.properties.each {k, v ->
println “$k: $v”
//retrieve individual property from ext
def propValue = project.ext.properties.get(“property_name”)
println “property_name: $propValue ”


prompt> gradle parseXml

Please add defaultEncoding property to your multipartresolver definition, as shown below.

<bean id=”multipartResolver” class=”org.springframework.web.multipart.commons.CommonsMultipartResolver”>

<property name=”defaultEncoding” value=”utf-8″/>

check your servlet filter if you have one, you can try setting request.setCharEncoding(“UTF-8″) in your filter.

you should have meta content type tag defined in your jsp, as shown below

<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″>

you may try, character-encoding=”utf-8″ for your spring form definition.

Posted by: bgopi | April 8, 2014

Heart bleed bug

Heart bleed bug is a serious vulnerability (CVE-2014-0160) in OpenSSL crypto, please go to heartbleed for more details. Fix is to update OpenSSL library version to 1.0.1g released yesterday (4/7/14). I tried to understand what is it and how it leaks data in memory,  here it is:

the heartbeat extension is used to check the connection is alive or not. Following snippet is from RFC-6250 : “The Heartbeat Extension provides a new protocol for TLS/DTLS allowing   the usage of keep-alive functionality without performing a  renegotiation and a basis for path MTU (PMTU) discovery for DTLS”.

This heartbeat works in such a way that when client sends heartbeat request message, server responds with the heartbeat response message. While sending the request, one can specify data size and data, max data allowed is 64 KB.  Then server response also contain 64 KB of data. This mechanism can be tricked by saying that you are sending 64 KB data but you really send 1 byte but server responds with 64 KB, your 1byte + 64KB-1 from memory (cooool, isn’t it), it could be sensitive information. And,if multiple requests are made, one may get multiple chunks of data from memory!



Below is the configuration need to be placed in your context.xml

<bean id=”dataSource” class=”org.springframework.jdbc.datasource.DriverManagerDataSource”>
<property name=”driverClassName” value=”org.hsqldb.jdbc.JDBCDriver”/>
<property name=”url” value=”jdbc:hsqldb:mem:testdb”/>
<property name=”username” value=”sa”/>
<property name=”password” value=””/>

<jdbc:initialize-database data-source=”dataSource”>
<jdbc:script location=”classpath:schema.sql”/>
<jdbc:script location=”classpath:data-sql.sql”/>

To visualize in memory database, you can use below  commands in terminal:

DatabaseManager – AWT UI:

java -cp <path_to_this_jar>/hsqldb-2.3.1.jar org.hsqldb.util.DatabaseManager –url jdbc:hsqldb:mem:testdb

E.g., java -cp ~/.m2/repository/org/hsqldb/hsqldb/2.3.1/hsqldb-2.3.1.jar org.hsqldb.util.DatabaseManager –url jdbc:hsqldb:mem:testdb

DatabaseManagerSwing – Swing UI:

java -cp <path_to_this_jar>/hsqldb-2.3.1.jar org.hsqldb.util.DatabaseManagerSwing –url jdbc:hsqldb:mem:testdb

e.g., java -cp ~/.m2/repository/org/hsqldb/hsqldb/2.3.1/hsqldb-2.3.1.jar org.hsqldb.util.DatabaseManagerSwing –url jdbc:hsqldb:mem:testdb

or you can embed below code in any java class:

org.hsqldb.util.DatabaseManagerSwing.main(new String[] {
“–url”, “jdbc:hsqldb:mem:testdb”

Posted by: bgopi | January 21, 2014

Spring 4 has been released – features listed here

Java 8 support (java 8 release due in March 14)

J2EE 7 support (JMS 2.0, JPA 2.1, Bean validation and concurrency utilities)

Web socket/HTML5 integration

Rest improvement- AsyncRestTemplate

Lamda expressions

Spring boot (dynamic language support)

Autowire using generic types (cool!)

Spring MVC improvement – @ControllerAdvice

and few others, please take a look at http://spring.io/blog/2013/12/12/announcing-spring-framework-4-0-ga-release

Older Posts »