spring-data-couchbase throws DocumentDoesNotExistException for non-existent documents - java

I am using spring-data-couchbase 2.1.2 with spring-boot 1.4.0.RC1 and couchbase-spring-cache
It works fine when caching is disabled as it returns NULL object When caching is enabled and try to find a non-existing document in the bucket it throws an exception:
com.couchbase.client.java.error.DocumentDoesNotExistException: null
at com.couchbase.client.java.CouchbaseAsyncBucket$22.call(CouchbaseAsyncBucket.java:684) ~[java-client-2.2.8.jar:na]
at com.couchbase.client.java.CouchbaseAsyncBucket$22.call(CouchbaseAsyncBucket.java:671) ~[java-client-2.2.8.jar:na]
at rx.internal.operators.OperatorMap$1.onNext(OperatorMap.java:54) ~[rxjava-1.0.17.jar:1.0.17]
at rx.observers.Subscribers$5.onNext(Subscribers.java:234) ~[rxjava-1.0.17.jar:1.0.17]
at rx.subjects.SubjectSubscriptionManager$SubjectObserver.onNext(SubjectSubscriptionManager.java:223) ~[rxjava-1.0.17.jar:1.0.17]
at rx.subjects.AsyncSubject.onCompleted(AsyncSubject.java:101) ~[rxjava-1.0.17.jar:1.0.17]
at com.couchbase.client.core.endpoint.AbstractGenericHandler.completeResponse(AbstractGenericHandler.java:354) ~[core-io-1.2.9.jar:na]
at com.couchbase.client.core.endpoint.AbstractGenericHandler.access$000(AbstractGenericHandler.java:72) ~[core-io-1.2.9.jar:na]
at com.couchbase.client.core.endpoint.AbstractGenericHandler$1.call(AbstractGenericHandler.java:372) ~[core-io-1.2.9.jar:na]
at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55) ~[rxjava-1.0.17.jar:1.0.17]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) ~[na:1.7.0_80]
at java.util.concurrent.FutureTask.run(FutureTask.java:262) ~[na:1.7.0_80]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178) ~[na:1.7.0_80]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292) ~[na:1.7.0_80]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) ~[na:1.7.0_80]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) ~[na:1.7.0_80]
at java.lang.Thread.run(Thread.java:745) ~[na:1.7.0_80]
Caused by: rx.exceptions.OnErrorThrowable$OnNextValue: OnError while emitting onNext value: com.couchbase.client.core.message.kv.RemoveResponse.class
at rx.exceptions.OnErrorThrowable.addValueAsLastCause(OnErrorThrowable.java:109) ~[rxjava-1.0.17.jar:1.0.17]
at rx.exceptions.Exceptions.throwOrReport(Exceptions.java:188) ~[rxjava-1.0.17.jar:1.0.17]
at rx.internal.operators.OperatorMap$1.onNext(OperatorMap.java:56) ~[rxjava-1.0.17.jar:1.0.17]
... 14 common frames omitted
Is it because of AsyncBucket? Is it possible to disable AsyncBucket?
Source code https://github.com/maverickmicky/spring-couchbase-cache

This is an issue indeed... As soon as an eviction attempt for a key that isn't in cache is made, the exception will be thrown :(
I've created an issue for this (with work arounds).
edit: To work around the issue, you should be able to declare a CacheErrorHandler that has a handleCacheEvictError method that simply catches DocumentDoesNotExistException.
See the documentation section on configuring the cache abstraction here and the CachingConfigurer javadoc.

I am across the same exception and use case is I am caching the resource which return null, for example:
#Override
#Cacheable(value = "EMPLOYEE_", key = "#id")
public Employee getEmployee(int id) {
return null;
}
And fixed it using the unless attribute of #Cacheable which is available as of Spring 3.2, as follows:
#Override
#Cacheable(value = "EMPLOYEE_", key = "#id", unless = "#result == null")
public Employee getEmployee(int id) {
return null;
}
Have written an article as well which describe my problem and fix for the same - Fixing com.couchbase.client.java.error.DocumentDoesNotExistException – Couchbase

Related

Couchbase server allowing concurrent document mutation, even with CAS set?

I have an object, SomeObject, which represents an object stored as a document in Couchbase. SomeObject has a cas variable for containing the CAS value.
I have code like this:
/* Get two identical objects from Couchbase, they'll have identical CAS value */
SomeObject someObjectA = getSomeObjectFromCouchbase(sameId);
SomeObject someObjectB = getSomeObjectFromCouchbase(sameId);
/* Make arbitrary modifications to the objects */
someObjectA.getListInObject().add(arbitraryValue1);
someObjectB.getListInObject().add(arbitraryValue2);
/* Convert SomeObject objects to JsonDocument objects, ensuring the CAS value is set */
JsonDocument jsonDocA = JsonDocument.create(someObjectA.getId(), JsonObject.fromJson(mapper.writeValueAsString(someObjectA)), someObjectA.getCas());
JsonDocument jsonDocB = JsonDocument.create(someObjectB.getId(), JsonObject.fromJson(mapper.writeValueAsString(someObjectB)), someObjectB.getCas());
/* Perform upserts on both JsonDocument objects; expectation is the second one should fail with CASMismatchException because the CAS value should have changed after the first upsert */
couchbaseDao.getDatasource().getBucket().upsert(jsonDocA, writeTimeout, TimeUnit.MILLISECONDS);
couchbaseDao.getDatasource().getBucket().upsert(jsonDocB, writeTimeout, TimeUnit.MILLISECONDS);
Despite my expectation that the second upsert should fail with CASMismatchException, which I attempt to catch by wrapping the code in a try/catch block, it does not happen. Both upserts succeed, and the server does indeed change the CAS value after both upserts. It's as if it's not even checking the CAS value upon upsert, just blindly accepting anything and then updating the CAS value.
The end result is that the list in the Couchbase document only contains arbitraryValue2, and is missing arbitraryValue1, whereas I expected it to have arbitraryValue1 and not arbitraryValue2 (as the second upsert should have thrown CASMismatchException). Am I doing something wrong, or is something wrong with the server such that it is not dealing with CAS properly?
CAS is just used in the replace method:
JsonDocument doc = userRepository.getCouchbaseOperations().getCouchbaseBucket().get("1");
JsonDocument doc2 = userRepository.getCouchbaseOperations().getCouchbaseBucket().get("1");
doc.content().put("username", "Michael");
userRepository.getCouchbaseOperations().getCouchbaseBucket().replace(doc);
doc2.content().put("username", "denis");
userRepository.getCouchbaseOperations().getCouchbaseBucket().replace(doc2);
User userResult2 = userRepository.findById("1").get();
System.out.println(userResult2.getUsername());
If you try to execute the code above you will get the following exception:
aused by: com.couchbase.client.java.error.CASMismatchException: null
at com.couchbase.client.java.bucket.api.Mutate$3$1.call(Mutate.java:333) ~[java-client-2.7.11.jar:na]
at com.couchbase.client.java.bucket.api.Mutate$3$1.call(Mutate.java:308) ~[java-client-2.7.11.jar:na]
at rx.internal.operators.OnSubscribeMap$MapSubscriber.onNext(OnSubscribeMap.java:69) ~[rxjava-1.3.8.jar:1.3.8]
at rx.observers.Subscribers$5.onNext(Subscribers.java:235) ~[rxjava-1.3.8.jar:1.3.8]
at rx.internal.operators.OnSubscribeDoOnEach$DoOnEachSubscriber.onNext(OnSubscribeDoOnEach.java:101) ~[rxjava-1.3.8.jar:1.3.8]
at rx.internal.producers.SingleProducer.request(SingleProducer.java:65) ~[rxjava-1.3.8.jar:1.3.8]
at rx.internal.producers.ProducerArbiter.setProducer(ProducerArbiter.java:126) ~[rxjava-1.3.8.jar:1.3.8]
at rx.internal.operators.OnSubscribeTimeoutTimedWithFallback$TimeoutMainSubscriber.setProducer(OnSubscribeTimeoutTimedWithFallback.java:155) ~[rxjava-1.3.8.jar:1.3.8]
at rx.Subscriber.setProducer(Subscriber.java:205) ~[rxjava-1.3.8.jar:1.3.8]
at rx.internal.operators.OnSubscribeMap$MapSubscriber.setProducer(OnSubscribeMap.java:102) ~[rxjava-1.3.8.jar:1.3.8]
at rx.Subscriber.setProducer(Subscriber.java:205) ~[rxjava-1.3.8.jar:1.3.8]
at rx.Subscriber.setProducer(Subscriber.java:205) ~[rxjava-1.3.8.jar:1.3.8]
at rx.subjects.AsyncSubject.onCompleted(AsyncSubject.java:103) ~[rxjava-1.3.8.jar:1.3.8]
at com.couchbase.client.core.endpoint.AbstractGenericHandler.completeResponse(AbstractGenericHandler.java:508) ~[core-io-1.7.11.jar:na]
at com.couchbase.client.core.endpoint.AbstractGenericHandler.access$000(AbstractGenericHandler.java:86) ~[core-io-1.7.11.jar:na]
at com.couchbase.client.core.endpoint.AbstractGenericHandler$1.call(AbstractGenericHandler.java:526) ~[core-io-1.7.11.jar:na]
at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55) ~[rxjava-1.3.8.jar:1.3.8]
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) ~[na:na]
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na]
at java.base/java.lang.Thread.run(Thread.java:835) ~[na:na]
Caused by: rx.exceptions.OnErrorThrowable$OnNextValue: OnError while emitting onNext value: com.couchbase.client.core.message.kv.ReplaceResponse.class
For the GO users here, I am using upsertSpec with CAS to figure out any parallel mutation on the doc. It does seem to work pretty well for me. Not sure about the java SDK though, Ideally behavior should be the same irrespective of language.

Not able to create custom Predicate while using fast aggregations in Hazelcast

I am creating a custom Predicate. It takes an integer and compares it with the value of map.
public class LocationPredicate implements Predicate<Key, Portable> {
private int rssi;
public LocationPredicate() {
}
public LocationPredicate(int rssi) {
this.rssi = rssi;
}
#Override
public boolean apply(Entry<Key, Aortable> arg0) {
return false;
//int val = arg0.getValue().getData().getLocation().getRssiVal();
//return (rssi == val ) ;
}
}
When I run the program, I am getting the following error:
Exception in thread "main" com.hazelcast.nio.serialization.HazelcastSerializationException: java.lang.ClassNotFoundException: com.snmpapp.main.LocationPredicate
at com.hazelcast.internal.serialization.impl.JavaDefaultSerializers$JavaSerializer.read(JavaDefaultSerializers.java:224)
at com.hazelcast.internal.serialization.impl.StreamSerializerAdapter.read(StreamSerializerAdapter.java:48)
at com.hazelcast.internal.serialization.impl.AbstractSerializationService.toObject(AbstractSerializationService.java:184)
at com.hazelcast.client.impl.protocol.task.map.MapAggregateWithPredicateMessageTask.getPredicate(MapAggregateWithPredicateMessageTask.java:45)
at com.hazelcast.client.impl.protocol.task.map.AbstractMapQueryMessageTask.call(AbstractMapQueryMessageTask.java:87)
at com.hazelcast.client.impl.protocol.task.AbstractCallableMessageTask.processMessage(AbstractCallableMessageTask.java:35)
at com.hazelcast.client.impl.protocol.task.AbstractMessageTask.initializeAndProcessMessage(AbstractMessageTask.java:123)
at com.hazelcast.client.impl.protocol.task.AbstractMessageTask.run(AbstractMessageTask.java:103)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
at com.hazelcast.util.executor.HazelcastManagedThread.executeRun(HazelcastManagedThread.java:64)
at com.hazelcast.util.executor.HazelcastManagedThread.run(HazelcastManagedThread.java:80)
at ------ submitted from ------.(Unknown Source)
at com.hazelcast.client.spi.impl.ClientInvocationFuture.resolveAndThrowIfException(ClientInvocationFuture.java:95)
at com.hazelcast.client.spi.impl.ClientInvocationFuture.resolveAndThrowIfException(ClientInvocationFuture.java:32)
at com.hazelcast.spi.impl.AbstractInvocationFuture.get(AbstractInvocationFuture.java:155)
at com.hazelcast.client.spi.ClientProxy.invoke(ClientProxy.java:172)
at com.hazelcast.client.proxy.ClientMapProxy.aggregate(ClientMapProxy.java:1356)
at com.snmpapp.main.Main.main(Main.java:370)
Caused by: java.lang.ClassNotFoundException: com.aruba.acp.snmpapp.main.LocationPredicate
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at com.hazelcast.nio.ClassLoaderUtil.tryLoadClass(ClassLoaderUtil.java:149)
at com.hazelcast.nio.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:123)
at com.hazelcast.nio.IOUtil$ClassLoaderAwareObjectInputStream.resolveClass(IOUtil.java:522)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1613)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1518)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1774)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:371)
at com.hazelcast.internal.serialization.impl.JavaDefaultSerializers$JavaSerializer.read(JavaDefaultSerializers.java:219)
at com.hazelcast.internal.serialization.impl.StreamSerializerAdapter.read(StreamSerializerAdapter.java:48)
at com.hazelcast.internal.serialization.impl.AbstractSerializationService.toObject(AbstractSerializationService.java:184)
at com.hazelcast.client.impl.protocol.task.map.MapAggregateWithPredicateMessageTask.getPredicate(MapAggregateWithPredicateMessageTask.java:45)
at com.hazelcast.client.impl.protocol.task.map.AbstractMapQueryMessageTask.call(AbstractMapQueryMessageTask.java:87)
at com.hazelcast.client.impl.protocol.task.AbstractCallableMessageTask.processMessage(AbstractCallableMessageTask.java:35)
at com.hazelcast.client.impl.protocol.task.AbstractMessageTask.initializeAndProcessMessage(AbstractMessageTask.java:123)
at com.hazelcast.client.impl.protocol.task.AbstractMessageTask.run(AbstractMessageTask.java:103)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
at com.hazelcast.util.executor.HazelcastManagedThread.executeRun(HazelcastManagedThread.java:64)
at com.hazelcast.util.executor.HazelcastManagedThread.run(HazelcastManagedThread.java:80)
I am little bit confused. Do I need to create the Predicate on the server? I am running as Hcast client and the client is creating the predicate.
As far as I know, when you create the predicate, it is sent as a serialized object to the hazelcast server.
Also, I tried to implement Predicate as Serializable, but it didnt help.
Thanks
I am not experienced with Hazelcast but as far as I know during serialisation and deserialisation you can transfer state (in this case the member variable) but not the behaviour (your actual implementation of apply method). Somehow (I am not experienced with this technology) you should provide your class to the Hazelcast's class loader (maybe copying to the classpath). Good luck!
The class needs to be on the classpath of all nodes.

Protobuf 3.0 Map causes java.lang.ExceptionInInitializerError: null in J9VM

Here is my proto:
proto
message TransactionRecord {
……
map<string, string> parameters = 19;
……
}
Then, I use following code to get a builder
java
final TransactionRecord.Builder metaDataBuilder = requestBuilder.getMetaData().toBuilder();
This code run fine in many JVMs, but fail in J9VM
Exception as following:
java.lang.ExceptionInInitializerError: null
at java.lang.J9VMInternals.initialize(J9VMInternals.java:222) ~[na:1.6.0]
at com.blueware.deps.com.google.protobuf.MapField.mergeFrom(MapField.java:204) ~[oneapm.jar:2.0]
at com.blueware.monitor.collector.grpc.TransactionRecord$Builder.mergeFrom(TransactionRecord.java:1323) ~[oneapm.jar:2.0]
at com.blueware.monitor.collector.grpc.TransactionRecord.toBuilder(TransactionRecord.java:1062) ~[oneapm.jar:2.0]
at com.blueware.monitor.transaction.TransactionDataCompressorFactoryService.compressMetaData(TransactionDataCompressorFactoryS
ervice.java:401) ~[oneapm.jar:2.0]
at com.blueware.monitor.transaction.TransactionDataCompressorFactoryService.compress(TransactionDataCompressorFactoryService.j
at weblogic.deploy.internal.targetserver.BasicDeployment.activateFromServerLifecycle(BasicDeployment.java:361) [weblogic.jar:1
0.3.6.0]
at weblogic.management.deploy.internal.ConfiguredDeployments.deployPreStandbyInternalApps(ConfiguredDeployments.java:85) [webl
ogic.jar:10.3.6.0]
at weblogic.management.deploy.internal.DeploymentServerService.deployPreStandbyInternalApps(DeploymentServerService.java:168)
[weblogic.jar:10.3.6.0]
at weblogic.management.deploy.internal.DeploymentPreStandbyServerService.start(DeploymentPreStandbyServerService.java:27) [web
logic.jar:10.3.6.0]
at weblogic.t3.srvr.SubsystemRequest.run(SubsystemRequest.java:64) [weblogic.jar:10.3.6.0]
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256) [com.bea.core.weblogic.workmanager_1.11.0.0.jar:1.11.0.0]
at weblogic.work.ExecuteThread.run(ExecuteThread.java:221) [com.bea.core.weblogic.workmanager_1.11.0.0.jar:1.11.0.0]
Caused by: java.lang.UnsupportedOperationException: null
at com.blueware.deps.com.google.protobuf.MapFieldLite.ensureMutable(MapFieldLite.java:221) ~[oneapm.jar:2.0]
at com.blueware.deps.com.google.protobuf.MapFieldLite.putAll(MapFieldLite.java:99) ~[oneapm.jar:2.0]
at java.util.LinkedHashMap.<init>(LinkedHashMap.java:112) ~[na:na]
at com.blueware.deps.com.google.protobuf.MapFieldLite.<init>(MapFieldLite.java:56) ~[oneapm.jar:2.0]
at com.blueware.deps.com.google.protobuf.MapFieldLite.<clinit>(MapFieldLite.java:61) ~[oneapm.jar:2.0]
at java.lang.J9VMInternals.initializeImpl(Native Method) ~[na:1.6.0]
at java.lang.J9VMInternals.initialize(J9VMInternals.java:200) ~[na:1.6.0]
... 45 common frames omitted
I have tried to remove map parameters for define, it goes fine.
Instead, I use final TransactionRecord.Builder metaDataBuilder = requestBuilder.getMetaDataBuilder();, that can't fix this issue. still failure on J9VM
How did this bug happen?
Is this a bug for map?
I have solve my problem. Have been confirmed, this is protobuf bug, when it's running on J9VM.
When static field EMPTY_MAP_FIELD in MapFieldLite is initilized on IBM J9, putAll which is overrided and calls ensureMutable. And ensureMutable is called in its super class LinkedHashMap, that causes UnsupportedOperationException is thrown, when isMutable has set to false at that time.
More info, you can read this RP.
RP has been merged by protobuf-java, RP is here

FirstSpirit : Synchronization content source raises IllegalArgumentException

When I try to sync my content sources, FirstSpirit is raising the exception:
java.lang.IllegalArgumentException: Entity xxx has no gid. Entities without gid are not supported.
Anyone knows how to fix this to make the sync successfully?
Thanks a lot in advance.
Admin (Admin), session: 5167312680662795708, project: 8385, ip: 169.254.30.75
(de.espirit.common.base.control.AbstractActionProcessor): [JC_Main]Handle failed [ActionEvent[AE#addElementsToSyncFolder,[<CONTENT2 editor="1" id="39967" name="brands" revision="10166" tabletemplate="103">
<LANG displayname="Brands" language="INTL"/>
<LANG displayname="Brands" language="DE"/>
<LANG displayname="Brands" language="EN-US"/>
<LANG displayname="Brands" language="ES-MX"/>
<CONTENTPARAMETER templateid="103"/>
</CONTENT2>
]]#898975197]!
FSVersion=5.2.212.71463#4747;JDK=1.8.0_101 64bit Oracle Corporation;OS=Windows 7 6.1 amd64;Date=07.10.2016 10:29:21
java.lang.IllegalArgumentException: Entity Brands [9] has no gid. Entities without gid are not supported.
at de.espirit.firstspirit.client.gui.navigation.ppool.sync.FileSystemSyncModelImpl.addEntities(FileSystemSyncModelImpl.java:374)
at de.espirit.firstspirit.client.gui.navigation.ppool.sync.FileSystemSyncModelImpl.add(FileSystemSyncModelImpl.java:216)
at de.espirit.firstspirit.client.gui.navigation.ppool.sync.FileSystemSyncModelImpl.add(FileSystemSyncModelImpl.java:179)
at de.espirit.firstspirit.client.gui.navigation.ppool.sync.FileSystemSyncHandler.handleAddElements(FileSystemSyncHandler.java:353)
at de.espirit.firstspirit.client.gui.navigation.ppool.sync.FileSystemSyncHandler.getHandle(FileSystemSyncHandler.java:259)
at sun.reflect.GeneratedMethodAccessor29.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at de.espirit.common.gui.RunsInEDTProxyFactory$RunsInEDTInvocationHandler.invoke(RunsInEDTProxyFactory.java:143)
at com.sun.proxy.$Proxy3.getHandle(Unknown Source)
at de.espirit.common.base.control.AbstractActionProcessor$ActionProcessDelegate.handle(AbstractActionProcessor.java:1099)
at de.espirit.common.base.control.AbstractActionProcessor$AbstractActionProcess.handle(AbstractActionProcessor.java:1283)
at de.espirit.common.base.control.AbstractActionProcessor$InnerActionProcess.handle(AbstractActionProcessor.java:1575)
at de.espirit.common.base.control.AbstractActionProcessor$InnerActionProcess$1.onGrant(AbstractActionProcessor.java:1558)
at de.espirit.common.base.control.AbstractActionProcessor$ActionProcessDelegate$1.handleGrantResult(AbstractActionProcessor.java:988)
at de.espirit.common.base.control.AbstractActionProcessor$ActionProcessDelegate$1.onGrant(AbstractActionProcessor.java:970)
at de.espirit.common.base.control.AbstractActionProcessor$ActionProcessDelegate$2.handleGrantResult(AbstractActionProcessor.java:1014)
at de.espirit.common.base.control.AbstractActionProcessor$ActionProcessDelegate$2.onSuccess(AbstractActionProcessor.java:1010)
at de.espirit.common.base.control.AbstractActionProcessor$ActionProcessDelegate$2.onSuccess(AbstractActionProcessor.java:1005)
at de.espirit.common.base.control.AbstractActionProcessor$ActionProcessDelegate$3.onGrant(AbstractActionProcessor.java:1035)
at de.espirit.common.base.control.AbstractActionProcessor$ActionProcessDelegate.grant(AbstractActionProcessor.java:956)
at de.espirit.common.base.control.AbstractActionProcessor$ActionProcessDelegate.requestGrant(AbstractActionProcessor.java:1029)
at de.espirit.common.base.control.AbstractActionProcessor$ActionProcessDelegate.grant(AbstractActionProcessor.java:993)
at de.espirit.common.base.control.AbstractActionProcessor$AbstractActionProcess.grant(AbstractActionProcessor.java:1278)
at de.espirit.common.base.control.AbstractActionProcessor$InnerActionProcess.grant(AbstractActionProcessor.java:1555)
at de.espirit.common.base.control.AbstractActionProcessor$InnerActionProcess.start(AbstractActionProcessor.java:1550)
at de.espirit.common.base.control.AbstractActionProcessor.doProcess(AbstractActionProcessor.java:435)
at de.espirit.common.base.control.AbstractActionProcessor.access$600(AbstractActionProcessor.java:37)
at de.espirit.common.base.control.AbstractActionProcessor$2.execute(AbstractActionProcessor.java:588)
at de.espirit.common.util.ExecutorScheduler$ExecuteCommand.run(ExecutorScheduler.java:123)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Entities need a GID (which is technically a UUID) for transport. It seems you've got an older project where this is not the case. You can use the de.espirit.firstspirit.common.GidAgent to assign GIDs to these entities first. This must be done only once, new entities get a GID automatically.

The trouble about the JCR multi-valued property when using JCR_GET_BY_ID

I'm using the Apache Camle version 2.14.0 with Apache Jackrabbit 2.8.0 and have found some trouble about the camel-jcr with JCR_GET_BY_ID when the node contains multi-valued property as the following: -
2014-09-26 10:19:21.604 [Client Event Poller] [] ERROR o.a.c.processor.DefaultErrorHandler
- 215 log Failed delivery for (
MessageId: ID-CharleeCh-53350-1411701537295-3-1 on
ExchangeId: ID-CharleeCh-53350-1411701537295-3-12).
Exhausted after delivery attempt: 1 caught:
javax.jcr.ValueFormatException: property /my-parent3/my-child31/myMuliple
is a multi-valued property, so it's values can only be retrieved as an array
Stacktrace
javax.jcr.ValueFormatException: property /my-parent3/my-child31/myMuliple
is a multi-valued property, so it's values can only be retrieved as an array
at org.apache.jackrabbit.rmi.server.ServerObject.getRepositoryException(ServerObject.java:139) ~[jackrabbit-jcr-rmi-2.8.0.jar:na]
at org.apache.jackrabbit.rmi.server.ServerProperty.getValue(ServerProperty.java:62) ~[jackrabbit-jcr-rmi-2.8.0.jar:na]
at sun.reflect.GeneratedMethodAccessor12.invoke(Unknown Source) ~[na:na]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_65]
at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_65]
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:322) ~[na:1.7.0_65]
at sun.rmi.transport.Transport$1.run(Transport.java:177) ~[na:1.7.0_65]
at sun.rmi.transport.Transport$1.run(Transport.java:174) ~[na:1.7.0_65]
at java.security.AccessController.doPrivileged(Native Method) ~[na:1.7.0_65]
at sun.rmi.transport.Transport.serviceCall(Transport.java:173) ~[na:1.7.0_65]
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:556) ~[na:1.7.0_65]
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:811) ~[na:1.7.0_65]
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:670) ~[na:1.7.0_65]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) ~[na:1.7.0_65]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) ~[na:1.7.0_65]
at java.lang.Thread.run(Thread.java:745) ~[na:1.7.0_65]
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:275) ~[na:1.7.0_65]
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:252) ~[na:1.7.0_65]
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:161) ~[na:1.7.0_65]
at org.apache.jackrabbit.rmi.server.ServerProperty_Stub.getValue(Unknown Source) ~[jackrabbit-jcr-rmi-2.8.0.jar:na]
at org.apache.jackrabbit.rmi.client.ClientProperty.getValue(ClientProperty.java:164) ~[jackrabbit-jcr-rmi-2.8.0.jar:na]
at org.apache.camel.component.jcr.JcrProducer.process(JcrProducer.java:69) ~[camel-jcr-2.14.0.jar:2.14.0]
I also have a chance to investigate to the camel-jcr source code, the org.apache.camel.component.jcr.JcrProducer, and found that it use the following:-
if (JcrConstants.JCR_INSERT.equals(operation)) {
...
for (String key : headers.keySet()) {
Value value = converter.convertTo(Value.class,
exchange,
message.getHeader(key));
...
}
...
} else if (JcrConstants.JCR_GET_BY_ID.equals(operation)) {
...
while (properties.hasNext()) {
Property property = properties.nextProperty();
Class<?> aClass = classForJCRType(property);
Object value = converter.convertTo(aClass,
exchange,
property.getValue());
...
}
} else {
throw new RuntimeException("Unsupported operation: " + operation);
}
Please correct me if I'm wrong. Since the code uses the Value.class and property.getValue() which is for the non-multi-valued. Does it mean that the camel-jcr does not provide the support to the multi-valued?
Do we have any workaround for supporting the multi-valued? At the moment I consider to replace the JcrProducer with my own interim fixing. Anyhow I thought that it may not be a proper way and would like your help to advise further
I've posted to the Camel User Group and found that it is a limitation for the current camel-jcr:2.14.0. I've fixed as the pull request.
I hope this may help other who faces the same issue.

Categories