Error in Java Client While Trying to Mutate Sub Document


#1

I have a document that looks like the following:

{
  "images": [],
  "quantity": null,
  "price": 10,
  "name": "Miku",
  "description": "Miku",
  "attributes": {
    "model": "Miku",
    "year": "2010",
    "make": "Miku",
    "mileage": "10000"
  },
  "type": "inventory-item"
}

In my code I am attempting to add an element to the images subdocument like the following:

bucket
    .mutateIn("item:1")
    .arrayAppend("images", "timestamp.png", true)
    .execute();

Assuming that bucket is already successfully opened from my cluster, and that the given document has the key “item:1”, this should work. However I get the following stack trace:

18:21:01,628 WARN  [com.couchbase.client.core.endpoint.ResponseStatusConverter] (cb-io-1-1) Unexpected ResponseStatus with Protocol KeyValue: ERR_ACCESS (0x24, No access)
18:21:01,629 ERROR [io.undertow.request] (default task-26) UT005023: Exception handling request to /trinary-inventory/v1/item/22/image: org.jboss.resteasy.spi.UnhandledException: com.couchbase.client.core.CouchbaseException: FAILURE
	at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:76) [resteasy-jaxrs-3.0.10.Final.jar:]
	at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:212) [resteasy-jaxrs-3.0.10.Final.jar:]
	at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:149) [resteasy-jaxrs-3.0.10.Final.jar:]
	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:372) [resteasy-jaxrs-3.0.10.Final.jar:]
	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:179) [resteasy-jaxrs-3.0.10.Final.jar:]
	at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:220) [resteasy-jaxrs-3.0.10.Final.jar:]
	at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56) [resteasy-jaxrs-3.0.10.Final.jar:]
	at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51) [resteasy-jaxrs-3.0.10.Final.jar:]
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) [jboss-servlet-api_3.1_spec-1.0.0.Final.jar:1.0.0.Final]
	at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:86) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]
	at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:130) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]
	at com.trinary.inventory.filter.SimpleCORSFilter.doFilter(SimpleCORSFilter.java:21) [classes:]
	at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]
	at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]
	at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:85) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]
	at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]
	at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]
	at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.8.Final.jar:1.1.8.Final]
	at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]
	at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]
	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.8.Final.jar:1.1.8.Final]
	at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) [undertow-core-1.1.8.Final.jar:1.1.8.Final]
	at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]
	at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58) [undertow-core-1.1.8.Final.jar:1.1.8.Final]
	at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]
	at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76) [undertow-core-1.1.8.Final.jar:1.1.8.Final]
	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.8.Final.jar:1.1.8.Final]
	at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.8.Final.jar:1.1.8.Final]
	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.8.Final.jar:1.1.8.Final]
	at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:261) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]
	at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:248) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]
	at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:77) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]
	at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:167) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]
	at io.undertow.server.Connectors.executeRootHandler(Connectors.java:199) [undertow-core-1.1.8.Final.jar:1.1.8.Final]
	at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:761) [undertow-core-1.1.8.Final.jar:1.1.8.Final]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [rt.jar:1.8.0_101]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.8.0_101]
	at java.lang.Thread.run(Unknown Source) [rt.jar:1.8.0_101]
Caused by: com.couchbase.client.core.CouchbaseException: FAILURE
	at com.couchbase.client.java.subdoc.SubdocHelper.commonSubdocErrors(SubdocHelper.java:95) [java-client-2.3.4.jar:]
	at com.couchbase.client.java.subdoc.AsyncMutateInBuilder$12.call(AsyncMutateInBuilder.java:921) [java-client-2.3.4.jar:]
	at com.couchbase.client.java.subdoc.AsyncMutateInBuilder$12.call(AsyncMutateInBuilder.java:915) [java-client-2.3.4.jar:]
	at com.couchbase.client.java.subdoc.AsyncMutateInBuilder$17.call(AsyncMutateInBuilder.java:1008) [java-client-2.3.4.jar:]
	at com.couchbase.client.java.subdoc.AsyncMutateInBuilder$17.call(AsyncMutateInBuilder.java:998) [java-client-2.3.4.jar:]
	at rx.internal.operators.OnSubscribeMap$MapSubscriber.onNext(OnSubscribeMap.java:69) [rxjava-1.1.8.jar:1.1.8]
	at rx.observers.Subscribers$5.onNext(Subscribers.java:235) [rxjava-1.1.8.jar:1.1.8]
	at rx.internal.producers.SingleProducer.request(SingleProducer.java:65) [rxjava-1.1.8.jar:1.1.8]
	at rx.Subscriber.setProducer(Subscriber.java:209) [rxjava-1.1.8.jar:1.1.8]
	at rx.Subscriber.setProducer(Subscriber.java:205) [rxjava-1.1.8.jar:1.1.8]
	at rx.internal.operators.OnSubscribeMap$MapSubscriber.setProducer(OnSubscribeMap.java:102) [rxjava-1.1.8.jar:1.1.8]
	at rx.Subscriber.setProducer(Subscriber.java:205) [rxjava-1.1.8.jar:1.1.8]
	at rx.subjects.AsyncSubject.onCompleted(AsyncSubject.java:106) [rxjava-1.1.8.jar:1.1.8]
	at com.couchbase.client.core.endpoint.AbstractGenericHandler.completeResponse(AbstractGenericHandler.java:349) [core-io-1.3.4.jar:]
	at com.couchbase.client.core.endpoint.AbstractGenericHandler.access$000(AbstractGenericHandler.java:67) [core-io-1.3.4.jar:]
	at com.couchbase.client.core.endpoint.AbstractGenericHandler$1.call(AbstractGenericHandler.java:367) [core-io-1.3.4.jar:]
	at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55) [rxjava-1.1.8.jar:1.1.8]
	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [rt.jar:1.8.0_101]
	at java.util.concurrent.FutureTask.run(Unknown Source) [rt.jar:1.8.0_101]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(Unknown Source) [rt.jar:1.8.0_101]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) [rt.jar:1.8.0_101]
	... 3 more
Caused by: rx.exceptions.OnErrorThrowable$OnNextValue: OnError while emitting onNext value: com.couchbase.client.core.message.kv.subdoc.simple.SimpleSubdocResponse.class
	at rx.exceptions.OnErrorThrowable.addValueAsLastCause(OnErrorThrowable.java:109) [rxjava-1.1.8.jar:1.1.8]
	at rx.internal.operators.OnSubscribeMap$MapSubscriber.onNext(OnSubscribeMap.java:73) [rxjava-1.1.8.jar:1.1.8]
	... 18 more

Please help me. I have been trying to figure out why this doesn’t work for quite a while now.


#2

Does this happen always? Which server version are you using? Subdoc feature is available only from couchbase server version 4.5. The error you are seeing is “No access (could be opcode, value, bucket etc)” from the server end, it could happen if you are running against a server version that doesn’t recognize a subdoc operation.


#3

Unfortunately I am on 4.1.6…

Am I able to get the enterprise version (4.5) without purchasing a license if my needs are non-commercial?


#4

Upgraded to 4.5! Thanks! That fixes it. The error message could be a little more clear =).


#5

You’re absolutely right @deusprogrammer, I’ve filed JCBC-1013.


#6

Otherwise, I have to say I am in love with Couchbase. It’s wonderful and easy to use. Once we are done with our prototype, we will definitely be purchasing a license.

And if there is anything I can do to help the community, please let me know. I have been a Java developer for quite a while =).


#7

@deusprogrammer awesome, we’ll improve the error message soon.

If you want to help out the community feel free to help others on the forums here (and in other parts of the internet like stack overflow) and if you feel in the mood for some coding we love contributions as well! If you are interested in contributing to the java-client you can read more about it here: https://github.com/couchbase/couchbase-java-client/blob/master/CONTRIBUTING.md and we are happy to help!