Getting "java.lang.RuntimeException: Failed to access the view" while querying?

What are the reasons of java.lang.RuntimeException: Failed to access the view. When trying to query using java I’m getting this error. When using the resultant startKey and endKey expression it works perfectly in Couchbase

startkey=[“456456”]&endkey=[“456456”,{}]

using the same in java gives error. Any suggestion?

Could you provide the Java code you’re trying to use to access the view?

Im using the below code :

String startString = “[”"+phoneNumber+""]";
String endString = “[”"+phoneNumber+"",{}]";
aQuery.setRange(startString, endString);
template.findByView(“design_name”, “viewName”, aQuery, Class.class);

findByView doesn’t seem to be in the Couchbase Java SDK. Is this a custom method from your code? Could you provide the actual code which calls the Couchbase SDK?

template here is of type CouchbaseTemplate, Im using Spring integrated with couch base. The javadoc for findViewById says
"Query a View for a list of documents of type T.
There is no need to Query.setIncludeDocs(boolean) explicitely, because it will be set to true all the time. It is valid to pass in a empty constructed Query object.

This method does not work with reduced views, because they by design do not contain references to original objects. Use the provided queryView method for more flexibility and direct access.

Specified by: findByView(…) in CouchbaseOperations
Parameters:
designName the name of the design document.
viewName the name of the viewName.
query the Query object to customize the viewName query.
entityClass the entity to map to.
Returns:
the converted collection"

I can’t really comment on Spring - perhaps try with the native Couchbase SDK API and get that working first?

Im not sure of the reason, but it started working. Another thing that I was doing incorrect was setting desc(true). Its working as expected now. Thanks