Unable to connect to CB server from virtual linux machine

CB Server: 2.5.0 enterprise edition (build-1059)
CB Java SDK: 1.2.3
i have checked on host machine following ports are open.
8091, 8092, 11211, 11210, 11209

I am developing hadoop map reduce job and trying to insert from reducer. currently i am just trying to insert 2 entries from testing point of view. I am using old API because latest api is not working with machine and giving some error of method not found.

here is the code i am using.

public class CBRepository {
List<URI> hosts = new ArrayList<URI>();
CouchbaseClient client;
String bucket = "servicedata";    
String password = "Digital123!";

public CBRepository() {
	try {
		
		CouchbaseConnectionFactoryBuilder cfb = new CouchbaseConnectionFactoryBuilder();
		cfb.setOpTimeout(10000);  // wait up to 10 seconds for an operation to succeed
        cfb.setOpQueueMaxBlockTime(5000); // wait up to 5 seconds when trying to enqueue an operation
        //cbserver is in  host file. ip is 10.0.2.2
		hosts.add(new URI("http://cbserver:8091/pools"));			
		client = new CouchbaseClient(cfb.buildCouchbaseConnection(hosts, bucket, password));
		
	} catch (Exception e) {
		// TODO Auto-generated catch block
		System.out.println(e.getMessage());
	}
}



public void set(Map<String, String> data) {
	
	try
	{
		for(Entry<String, String> entry : data.entrySet()) {
		    String objKey= entry.getKey();
		    String value = entry.getValue();
		    
		    client.set(objKey, 0, value);
		    			    
		}
		
		//client.shutdown();
	}
	catch(Exception e)
	{
		System.out.println(e.getStackTrace());
	}

}

thats how I Am using this repository.

Map dictionary = new HashMap(); dictionary.put("job1", "data1"); dictionary.put("job2", "data2"); CBRepository cbRep = new CBRepository(); cbRep.set(dictionary);

and I am getting following in the error.
2014-08-27 03:26:05.802 INFO com.couchbase.client.CouchbaseConnection: Added {QA sa=/127.0.0.1:11210, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0} to connect queue
2014-08-27 03:26:05.817 INFO com.couchbase.client.CouchbaseConnection: Connection state changed for sun.nio.ch.SelectionKeyImpl@66b45d8e
2014-08-27 03:26:05.819 INFO com.couchbase.client.CouchbaseConnection: Reconnecting due to failure to connect to {QA sa=localhost.localdomain/127.0.0.1:11210, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0}
java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:735)
at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:629)
at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:409)
at com.couchbase.client.CouchbaseConnection.run(CouchbaseConnection.java:288)
2014-08-27 03:26:05.821 WARN com.couchbase.client.CouchbaseConnection: Closing, and reopening {QA sa=localhost.localdomain/127.0.0.1:11210, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0}, attempt 1.
2014-08-27 03:26:05.882 INFO com.couchbase.client.ViewConnection: Added localhost.localdomain to connect queue
2014-08-27 03:26:05.886 INFO com.couchbase.client.CouchbaseClient: viewmode property isn’t defined. Setting viewmode to production mode
2014-08-27 03:26:06.108 INFO com.couchbase.client.CouchbaseConnectionFactoryBuilder$1: Replacing current streaming node list [http://cbserver:8091/pools] with [http://127.0.0.1:8091/pools]
2014-08-27 03:26:06.180 WARN com.couchbase.client.CouchbaseConnection: Node expected to receive data is inactive. This could be due to a failure within the cluster. Will check for updated configuration. Key without a configured node is: job1.
2014-08-27 03:26:07.182 WARN net.spy.memcached.protocol.binary.BinaryMemcachedNodeImpl: Operation canceled because authentication or reconnection and authentication has taken more than one second to complete.
2014-08-27 03:26:07.183 WARN com.couchbase.client.CouchbaseConnection: Node expected to receive data is inactive. This could be due to a failure within the cluster. Will check for updated configuration. Key without a configured node is: job2.
2014-08-27 03:26:08.184 WARN net.spy.memcached.protocol.binary.BinaryMemcachedNodeImpl: Operation canceled because authentication or reconnection and authentication has taken more than one second to complete.

Please have a look and suggest what else i can do to resolve the problem.

Thanks.

The Couchbase Server is using 127.0.0.1 and not 10.0.2.2.

When the client connects it get the cluster map however that has 127.0.0.1 as the ip address of the node and then the client tries to connect to that address. When you initiated the node if you set the hostname to the correct IP or hostname it should work.

The manual covers this in more details:

http://docs.couchbase.com/couchbase-manual-2.5/cb-install/#using-hostnames

IP 10.0.2.2 is given to host machine by virtual machine. when I try to enter this IP on CB setup it doesnt accept it and says it is not valid ip (“Could not listen: eaddrnotavail”).

any suggestion ??