JAVA SDK 1.1 - ArrayOutOfBoundException when using client.add with persistTo.MASTER

Hi, Greetings ! I am a new developer with Couchbase SDK and I was trying a basic .add method to add a document to Couchbase. I have setup my Couchbase server mostly as per the default instructions. Here’s the code block
try
{
client.add(“foo”, expireTime, “bar”, PersistTo.MASTER);
System.out.println(client.get(“foo”));
}
catch (Exception ex)
{
ex.printStackTrace();
}

The reason I am using PersistTo.MASTER is because I want to wait (I am guessing the right terminology is “observe”?) till the document gets persisted to the disk (so it’s readily available for query through views).
While I do this, I am getting an ArrayOutOfBoundException: -1. Here’s the stacktrace:

java.lang.ArrayIndexOutOfBoundsException: -1
at java.util.ArrayList.elementData(ArrayList.java:371)
at java.util.ArrayList.elementData(ArrayList.java:371)
at java.util.ArrayList.get(ArrayList.java:384 at java.util.ArrayList.get(ArrayList.java:384)
)
at com.couchbase.client.vbucket.config.DefaultConfig.getServer(DefaultConfig.java:81)
at com.couchbase.client.vbucket.config.DefaultConfig.getServer(DefaultConfig.java:81)
at com.couchbase.client.vbucket.VBucketNodeLocator.getServerByIndex(VBucketNodeLocator.java:112)
at com.couchbase.client.vbucket.VBucketNodeLocator.getServerByIndex(VBucketNodeLocator.java:112)
at com.couchbase.client.CouchbaseClient.observe(CouchbaseClient.java:1621)
at com.couchbase.client.CouchbaseClient.observe(CouchbaseClient.java:1621)
at com.couchbase.client.CouchbaseClient.observePoll(CouchbaseClient.java:1750)
at com.couchbase.client.CouchbaseClient.observePoll(CouchbaseClient.java:1750)
at com.couchbase.client.CouchbaseClient.add(CouchbaseClient.java:1312)
at com.couchbase.client.CouchbaseClient.add(CouchbaseClient.java:1312)
at com.couchbase.client.CouchbaseClient.add(CouchbaseClient.java:1344)
at com.couchbase.client.CouchbaseClient.add(CouchbaseClient.java:1344)

Is there something fundamentally wrong with my code or am I missing something?
The document does get added/created on the server (atleast I do get it back when I do a .get(“foo”)) but I am not sure if it ACTUALLY gets persisted to the disk because of that error and IF the document is actually persisted and ready to be queried though view.

All help appreciated. Please advise!
Thanks,
Shivang

Hello,
It is a known issue that has been fixed in 1.1.2:
http://www.couchbase.com/issues/browse/JCBC-223
As a workaround, if you cannot upgrade immediately (best option), you have to set the number of replicas on your bucket to 0 (that is ok since you are on a single node installation - I guessed.
Regards

You guessed right ! Thank you so much for the prompt response. I will try with 0 and if not, will upgrade the API.
One more question I had was, I wanted to know the best practices on when Views should be used instead of reference documents and what are the pros and cons of used each.
If you can just point me to the right documentation, that will be great! Couchbase Manual does tell me what reference documents and views are, but doesn’t tell me what are the best scenarios to use each.
Thanks again!
Cheers,
Shivang