-
Bug
-
Resolution: Done
-
Major
-
12.0.1.Final
-
None
When putting a custom object with jboss-marshalling on Infinispan 12 for WildFly modules, it fails with the following ClassNotFoundException:
- ERROR occurred due to ClassNotFoundException on the remote node
ERROR [org.infinispan.interceptors.impl.InvocationContextInterceptor] (jgroups-12,t420-26164) ISPN000136: Error executing command VersionedPrepareCommand on Cache 'test1', writing keys [k1615449309513]: org.infinispan.remoting.RemoteException: ISPN000217: Received exception from t420-13638, see cause for remote stack trace at org.infinispan:ispn-12.0//org.infinispan.remoting.transport.ResponseCollectors.wrapRemoteException(ResponseCollectors.java:25) at org.infinispan:ispn-12.0//org.infinispan.remoting.transport.impl.MapResponseCollector.addException(MapResponseCollector.java:65) at org.infinispan:ispn-12.0//org.infinispan.remoting.transport.impl.MapResponseCollector$IgnoreLeavers.addException(MapResponseCollector.java:103) at org.infinispan:ispn-12.0//org.infinispan.remoting.transport.ValidResponseCollector.addResponse(ValidResponseCollector.java:29) at org.infinispan:ispn-12.0//org.infinispan.remoting.transport.impl.MultiTargetRequest.onResponse(MultiTargetRequest.java:92) at org.infinispan:ispn-12.0//org.infinispan.remoting.transport.impl.RequestRepository.addResponse(RequestRepository.java:51) at org.infinispan:ispn-12.0//org.infinispan.remoting.transport.jgroups.JGroupsTransport.processResponse(JGroupsTransport.java:1407) at org.infinispan:ispn-12.0//org.infinispan.remoting.transport.jgroups.JGroupsTransport.processMessage(JGroupsTransport.java:1310) at org.infinispan:ispn-12.0//org.infinispan.remoting.transport.jgroups.JGroupsTransport.access$300(JGroupsTransport.java:131) at org.infinispan:ispn-12.0//org.infinispan.remoting.transport.jgroups.JGroupsTransport$ChannelCallbacks.up(JGroupsTransport.java:1450) at org.infinispan:ispn-12.0//org.jgroups.JChannel.up(JChannel.java:784) at org.infinispan:ispn-12.0//org.jgroups.stack.ProtocolStack.up(ProtocolStack.java:913) at org.infinispan:ispn-12.0//org.jgroups.protocols.FRAG3.up(FRAG3.java:165) at org.infinispan:ispn-12.0//org.jgroups.protocols.FlowControl.up(FlowControl.java:343) at org.infinispan:ispn-12.0//org.jgroups.protocols.FlowControl.up(FlowControl.java:343) at org.infinispan:ispn-12.0//org.jgroups.protocols.pbcast.GMS.up(GMS.java:876) at org.infinispan:ispn-12.0//org.jgroups.protocols.pbcast.STABLE.up(STABLE.java:243) at org.infinispan:ispn-12.0//org.jgroups.protocols.UNICAST3.deliverMessage(UNICAST3.java:1049) at org.infinispan:ispn-12.0//org.jgroups.protocols.UNICAST3.addMessage(UNICAST3.java:772) at org.infinispan:ispn-12.0//org.jgroups.protocols.UNICAST3.handleDataReceived(UNICAST3.java:753) at org.infinispan:ispn-12.0//org.jgroups.protocols.UNICAST3.up(UNICAST3.java:405) at org.infinispan:ispn-12.0//org.jgroups.protocols.pbcast.NAKACK2.up(NAKACK2.java:592) at org.infinispan:ispn-12.0//org.jgroups.protocols.VERIFY_SUSPECT.up(VERIFY_SUSPECT.java:132) at org.infinispan:ispn-12.0//org.jgroups.protocols.FailureDetection.up(FailureDetection.java:186) at org.infinispan:ispn-12.0//org.jgroups.protocols.FD_SOCK.up(FD_SOCK.java:254) at org.infinispan:ispn-12.0//org.jgroups.protocols.MERGE3.up(MERGE3.java:281) at org.infinispan:ispn-12.0//org.jgroups.protocols.Discovery.up(Discovery.java:300) at org.infinispan:ispn-12.0//org.jgroups.protocols.TP.passMessageUp(TP.java:1396) at org.infinispan:ispn-12.0//org.jgroups.util.SubmitToThreadPool$SingleMessageHandler.run(SubmitToThreadPool.java:87) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:834) Caused by: org.infinispan.commons.marshall.MarshallingException: java.lang.ClassNotFoundException: com.example.ExampleObject from [Module "org.infinispan:ispn-12.0" from local module loader @47f9738 (finder: local module finder @6155d082 (roots: /tmp/wildfly-21.0.1.Final/modules,/tmp/wildfly-21.0.1.Final/modules/system/layers/base,/tmp/wildfly-21.0.1.Final/modules/system/add-ons/ispn))] at org.infinispan:ispn-12.0//org.infinispan.marshall.exts.ThrowableExternalizer.readObject(ThrowableExternalizer.java:227) at org.infinispan:ispn-12.0//org.infinispan.marshall.exts.ThrowableExternalizer.readObject(ThrowableExternalizer.java:42) at org.infinispan:ispn-12.0//org.infinispan.marshall.core.GlobalMarshaller.readWithExternalizer(GlobalMarshaller.java:727) at org.infinispan:ispn-12.0//org.infinispan.marshall.core.GlobalMarshaller.readNonNullableObject(GlobalMarshaller.java:708) at org.infinispan:ispn-12.0//org.infinispan.marshall.core.GlobalMarshaller.readNullableObject(GlobalMarshaller.java:357) at org.infinispan:ispn-12.0//org.infinispan.marshall.core.BytesObjectInput.readObject(BytesObjectInput.java:32) at org.infinispan:ispn-12.0//org.infinispan.remoting.responses.ExceptionResponse$Externalizer.readObject(ExceptionResponse.java:49) at org.infinispan:ispn-12.0//org.infinispan.remoting.responses.ExceptionResponse$Externalizer.readObject(ExceptionResponse.java:41) at org.infinispan:ispn-12.0//org.infinispan.marshall.core.GlobalMarshaller.readWithExternalizer(GlobalMarshaller.java:727) at org.infinispan:ispn-12.0//org.infinispan.marshall.core.GlobalMarshaller.readNonNullableObject(GlobalMarshaller.java:708) at org.infinispan:ispn-12.0//org.infinispan.marshall.core.GlobalMarshaller.readNullableObject(GlobalMarshaller.java:357) at org.infinispan:ispn-12.0//org.infinispan.marshall.core.GlobalMarshaller.objectFromObjectInput(GlobalMarshaller.java:191) at org.infinispan:ispn-12.0//org.infinispan.marshall.core.GlobalMarshaller.objectFromByteBuffer(GlobalMarshaller.java:220) at org.infinispan:ispn-12.0//org.infinispan.remoting.transport.jgroups.JGroupsTransport.processResponse(JGroupsTransport.java:1399) ... 25 more Caused by: java.lang.ClassNotFoundException: com.example.ExampleObject from [Module "org.infinispan:ispn-12.0" from local module loader @47f9738 (finder: local module finder @6155d082 (roots: /tmp/wildfly-21.0.1.Final/modules,/tmp/wildfly-21.0.1.Final/modules/system/layers/base,/tmp/wildfly-21.0.1.Final/modules/system/add-ons/ispn))] at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490) at org.infinispan:ispn-12.0//org.infinispan.marshall.exts.ThrowableExternalizer.readGenericThrowable(ThrowableExternalizer.java:282) at org.infinispan:ispn-12.0//org.infinispan.marshall.exts.ThrowableExternalizer.readObject(ThrowableExternalizer.java:259) at org.infinispan:ispn-12.0//org.infinispan.marshall.exts.ThrowableExternalizer.readObject(ThrowableExternalizer.java:42) at org.infinispan:ispn-12.0//org.infinispan.marshall.core.GlobalMarshaller.readWithExternalizer(GlobalMarshaller.java:727) at org.infinispan:ispn-12.0//org.infinispan.marshall.core.GlobalMarshaller.readNonNullableObject(GlobalMarshaller.java:708) at org.infinispan:ispn-12.0//org.infinispan.marshall.core.GlobalMarshaller.readNullableObject(GlobalMarshaller.java:357) at org.infinispan:ispn-12.0//org.infinispan.marshall.core.BytesObjectInput.readObject(BytesObjectInput.java:32) at org.infinispan:ispn-12.0//org.infinispan.marshall.exts.ThrowableExternalizer.readObject(ThrowableExternalizer.java:226) ... 38 more
- ClassNotFoundException on the remote node
ERROR [org.infinispan.CLUSTER] (jgroups-6,t420-13638) ISPN000474: Error processing request 7@t420-26164: org.infinispan.commons.marshall.MarshallingException: java.lang.ClassNotFoundException: com.example.ExampleObject from [Module "org.infinispan:ispn-12.0" from local module loader @47f9738 (finder: local module finder @6155d082 (roots: /tmp/wildfly-21.0.1.Final/modules,/tmp/wildfly-21.0.1.Final/modules/system/layers/base,/tmp/wildfly-21.0.1.Final/modules/system/add-ons/ispn))] at org.infinispan:ispn-12.0//org.infinispan.marshall.protostream.impl.MarshallableUserObject$Marshaller.readFrom(MarshallableUserObject.java:141) at org.infinispan:ispn-12.0//org.infinispan.marshall.protostream.impl.MarshallableUserObject$Marshaller.readFrom(MarshallableUserObject.java:102) at org.infinispan:ispn-12.0//org.infinispan.protostream.impl.RawProtobufMarshallerDelegate.unmarshall(RawProtobufMarshallerDelegate.java:37) at org.infinispan:ispn-12.0//org.infinispan.protostream.WrappedMessage.readMessage(WrappedMessage.java:390) at org.infinispan:ispn-12.0//org.infinispan.protostream.ProtobufUtil.fromWrappedByteArray(ProtobufUtil.java:114) at org.infinispan:ispn-12.0//org.infinispan.marshall.protostream.impl.AbstractInternalProtoStreamMarshaller.objectFromByteBuffer(AbstractInternalProtoStreamMarshaller.java:97) at org.infinispan:ispn-12.0//org.infinispan.marshall.protostream.impl.AbstractInternalProtoStreamMarshaller.objectFromByteBuffer(AbstractInternalProtoStreamMarshaller.java:92) at org.infinispan:ispn-12.0//org.infinispan.marshall.core.GlobalMarshaller.readUnknown(GlobalMarshaller.java:905) at org.infinispan:ispn-12.0//org.infinispan.marshall.core.GlobalMarshaller.readUnknown(GlobalMarshaller.java:890) at org.infinispan:ispn-12.0//org.infinispan.marshall.core.GlobalMarshaller.readNonNullableObject(GlobalMarshaller.java:714) at org.infinispan:ispn-12.0//org.infinispan.marshall.core.GlobalMarshaller.readNullableObject(GlobalMarshaller.java:357) at org.infinispan:ispn-12.0//org.infinispan.marshall.core.BytesObjectInput.readObject(BytesObjectInput.java:32) at org.infinispan:ispn-12.0//org.infinispan.commands.write.PutKeyValueCommand.readFrom(PutKeyValueCommand.java:96) at org.infinispan:ispn-12.0//org.infinispan.marshall.exts.ReplicableCommandExternalizer.readCommandParameters(ReplicableCommandExternalizer.java:116) at org.infinispan:ispn-12.0//org.infinispan.marshall.exts.ReplicableCommandExternalizer.readObject(ReplicableCommandExternalizer.java:105) at org.infinispan:ispn-12.0//org.infinispan.marshall.exts.ReplicableCommandExternalizer.readObject(ReplicableCommandExternalizer.java:67) at org.infinispan:ispn-12.0//org.infinispan.marshall.core.GlobalMarshaller.readWithExternalizer(GlobalMarshaller.java:727) at org.infinispan:ispn-12.0//org.infinispan.marshall.core.GlobalMarshaller.readNonNullableObject(GlobalMarshaller.java:708) at org.infinispan:ispn-12.0//org.infinispan.marshall.core.GlobalMarshaller.readNullableObject(GlobalMarshaller.java:357) at org.infinispan:ispn-12.0//org.infinispan.marshall.core.BytesObjectInput.readObject(BytesObjectInput.java:32) at org.infinispan:ispn-12.0//org.infinispan.commons.marshall.MarshallUtil.unmarshallArray(MarshallUtil.java:214) at org.infinispan:ispn-12.0//org.infinispan.commands.tx.PrepareCommand.readFrom(PrepareCommand.java:236) at org.infinispan:ispn-12.0//org.infinispan.commands.tx.VersionedPrepareCommand.readFrom(VersionedPrepareCommand.java:62) at org.infinispan:ispn-12.0//org.infinispan.marshall.exts.ReplicableCommandExternalizer.readCommandParameters(ReplicableCommandExternalizer.java:116) at org.infinispan:ispn-12.0//org.infinispan.marshall.exts.CacheRpcCommandExternalizer.readObject(CacheRpcCommandExternalizer.java:156) at org.infinispan:ispn-12.0//org.infinispan.marshall.exts.CacheRpcCommandExternalizer.readObject(CacheRpcCommandExternalizer.java:82) at org.infinispan:ispn-12.0//org.infinispan.marshall.core.GlobalMarshaller.readWithExternalizer(GlobalMarshaller.java:727) at org.infinispan:ispn-12.0//org.infinispan.marshall.core.GlobalMarshaller.readNonNullableObject(GlobalMarshaller.java:708) at org.infinispan:ispn-12.0//org.infinispan.marshall.core.GlobalMarshaller.readNullableObject(GlobalMarshaller.java:357) at org.infinispan:ispn-12.0//org.infinispan.marshall.core.GlobalMarshaller.objectFromObjectInput(GlobalMarshaller.java:191) at org.infinispan:ispn-12.0//org.infinispan.marshall.core.GlobalMarshaller.objectFromByteBuffer(GlobalMarshaller.java:220) at org.infinispan:ispn-12.0//org.infinispan.remoting.transport.jgroups.JGroupsTransport.processRequest(JGroupsTransport.java:1367) at org.infinispan:ispn-12.0//org.infinispan.remoting.transport.jgroups.JGroupsTransport.processMessage(JGroupsTransport.java:1307) at org.infinispan:ispn-12.0//org.infinispan.remoting.transport.jgroups.JGroupsTransport.access$300(JGroupsTransport.java:131) at org.infinispan:ispn-12.0//org.infinispan.remoting.transport.jgroups.JGroupsTransport$ChannelCallbacks.up(JGroupsTransport.java:1450) at org.infinispan:ispn-12.0//org.jgroups.JChannel.up(JChannel.java:784) at org.infinispan:ispn-12.0//org.jgroups.stack.ProtocolStack.up(ProtocolStack.java:913) at org.infinispan:ispn-12.0//org.jgroups.protocols.FRAG3.up(FRAG3.java:165) at org.infinispan:ispn-12.0//org.jgroups.protocols.FlowControl.up(FlowControl.java:359) at org.infinispan:ispn-12.0//org.jgroups.protocols.FlowControl.up(FlowControl.java:351) at org.infinispan:ispn-12.0//org.jgroups.protocols.pbcast.GMS.up(GMS.java:876) at org.infinispan:ispn-12.0//org.jgroups.protocols.pbcast.STABLE.up(STABLE.java:243) at org.infinispan:ispn-12.0//org.jgroups.protocols.UNICAST3.up(UNICAST3.java:392) at org.infinispan:ispn-12.0//org.jgroups.protocols.pbcast.NAKACK2.deliver(NAKACK2.java:931) at org.infinispan:ispn-12.0//org.jgroups.protocols.pbcast.NAKACK2.handleMessage(NAKACK2.java:821) at org.infinispan:ispn-12.0//org.jgroups.protocols.pbcast.NAKACK2.up(NAKACK2.java:602) at org.infinispan:ispn-12.0//org.jgroups.protocols.VERIFY_SUSPECT.up(VERIFY_SUSPECT.java:132) at org.infinispan:ispn-12.0//org.jgroups.protocols.FailureDetection.up(FailureDetection.java:186) at org.infinispan:ispn-12.0//org.jgroups.protocols.FD_SOCK.up(FD_SOCK.java:254) at org.infinispan:ispn-12.0//org.jgroups.protocols.MERGE3.up(MERGE3.java:281) at org.infinispan:ispn-12.0//org.jgroups.protocols.Discovery.up(Discovery.java:300) at org.infinispan:ispn-12.0//org.jgroups.protocols.TP.passMessageUp(TP.java:1396) at org.infinispan:ispn-12.0//org.jgroups.util.SubmitToThreadPool$SingleMessageHandler.run(SubmitToThreadPool.java:87) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:834) Caused by: java.lang.ClassNotFoundException: com.example.ExampleObject from [Module "org.infinispan:ispn-12.0" from local module loader @47f9738 (finder: local module finder @6155d082 (roots: /tmp/wildfly-21.0.1.Final/modules,/tmp/wildfly-21.0.1.Final/modules/system/layers/base,/tmp/wildfly-21.0.1.Final/modules/system/add-ons/ispn))] at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:255) at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:410) at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398) at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:116) at java.base/java.lang.Class.forName0(Native Method) at java.base/java.lang.Class.forName(Class.java:398) at org.infinispan:ispn-12.0//org.jboss.marshalling.AbstractClassResolver.loadClass(AbstractClassResolver.java:129) at org.infinispan:ispn-12.0//org.jboss.marshalling.AbstractClassResolver.resolveClass(AbstractClassResolver.java:110) at org.infinispan:ispn-12.0//org.infinispan.jboss.marshalling.commons.CheckedClassResolver.resolveClass(CheckedClassResolver.java:31) at org.infinispan:ispn-12.0//org.jboss.marshalling.river.RiverUnmarshaller.doReadClassDescriptor(RiverUnmarshaller.java:1033) at org.infinispan:ispn-12.0//org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1366) at org.infinispan:ispn-12.0//org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:283) at org.infinispan:ispn-12.0//org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:216) at org.infinispan:ispn-12.0//org.jboss.marshalling.AbstractObjectInput.readObject(AbstractObjectInput.java:41) at org.infinispan:ispn-12.0//org.infinispan.jboss.marshalling.commons.AbstractJBossMarshaller.objectFromObjectStream(AbstractJBossMarshaller.java:137) at org.infinispan:ispn-12.0//org.infinispan.jboss.marshalling.commons.AbstractJBossMarshaller.objectFromByteBuffer(AbstractJBossMarshaller.java:115) at org.infinispan:ispn-12.0//org.infinispan.commons.marshall.AbstractMarshaller.objectFromByteBuffer(AbstractMarshaller.java:82) at org.infinispan:ispn-12.0//org.infinispan.marshall.core.impl.DelegatingUserMarshaller.objectFromByteBuffer(DelegatingUserMarshaller.java:63) at org.infinispan:ispn-12.0//org.infinispan.marshall.protostream.impl.MarshallableUserObject$Marshaller.readFrom(MarshallableUserObject.java:138) ... 55 more
The constructor of GenericJBossMarshaller uses "getClass().getClassLoader()" as a classloader for ClassResovler (== using the classloader of the Infinispan WildFly modules "org.infinispan:ispn-12.0") when no class loader is specified. As the Infinispan WildFly modules can not access the application class, this causes the above ClassNotFoundException.
I think GenericJBossMarshaller should use "Thread.currentThread().getContextClassLoader()" instead like the following:
diff --git a/jboss-marshalling/src/main/java/org/infinispan/jboss/marshalling/commons/GenericJBossMarshaller.java b/jboss-marshalling/src/main/java/org/infinispan/jboss/marshalling/commons/GenericJBossMarshaller.java index 3c674a7..cf7dc25 100644 --- a/jboss-marshalling/src/main/java/org/infinispan/jboss/marshalling/commons/GenericJBossMarshaller.java +++ b/jboss-marshalling/src/main/java/org/infinispan/jboss/marshalling/commons/GenericJBossMarshaller.java @@ -28,7 +28,7 @@ public GenericJBossMarshaller(ClassAllowList classAllowList) { public GenericJBossMarshaller(ClassLoader classLoader, ClassAllowList classAllowList) { super(); if (classLoader == null) { - classLoader = getClass().getClassLoader(); + classLoader = Thread.currentThread().getContextClassLoader(); } baseCfg.setClassResolver(classAllowList == null ? new DefaultContextClassResolver(classLoader) :