JBoss Infinispan cache throws ISPN000097 Failure to marshal argument(s) exception in EAP

Solution Unverified - Updated -

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 6.x
    • 7.x

Issue

  • While running a web application in clustered mode JBoss Infinispan cache throws the following exception :
 ERROR [org.infinispan.transaction.TransactionCoordinator] (http-/127.0.0.1:8180-1) ISPN000097: Error while processing a prepare in a single-phase transaction: org.infinispan.CacheException: java.lang.RuntimeException: Failure to marshal argument(s)
    at org.infinispan.util.Util.rewrapAsCacheException(Util.java:526)
    at org.infinispan.remoting.transport.jgroups.CommandAwareRpcDispatcher.invokeRemoteCommand(CommandAwareRpcDispatcher.java:172)
    at org.infinispan.remoting.transport.jgroups.JGroupsTransport.invokeRemotely(JGroupsTransport.java:489)
    at org.infinispan.remoting.rpc.RpcManagerImpl.invokeRemotely(RpcManagerImpl.java:161)
    at org.infinispan.remoting.rpc.RpcManagerImpl.invokeRemotely(RpcManagerImpl.java:183)
    at org.infinispan.remoting.rpc.RpcManagerImpl.invokeRemotely(RpcManagerImpl.java:240)
    at org.infinispan.remoting.rpc.RpcManagerImpl.invokeRemotely(RpcManagerImpl.java:227)
    at org.infinispan.remoting.rpc.RpcManagerImpl.invokeRemotely(RpcManagerImpl.java:222)
    at org.infinispan.remoting.rpc.RpcManagerImpl.broadcastRpcCommand(RpcManagerImpl.java:201)
    at org.infinispan.interceptors.ReplicationInterceptor.broadcastPrepare(ReplicationInterceptor.java:136)
    at org.infinispan.interceptors.ReplicationInterceptor.visitPrepareCommand(ReplicationInterceptor.java:128)
    at org.infinispan.commands.tx.PrepareCommand.acceptVisitor(PrepareCommand.java:133)
    at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116)
    at org.infinispan.interceptors.base.CommandInterceptor.handleDefault(CommandInterceptor.java:130)
    at org.infinispan.commands.AbstractVisitor.visitPrepareCommand(AbstractVisitor.java:126)
    at org.infinispan.commands.tx.PrepareCommand.acceptVisitor(PrepareCommand.java:133)
    at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116)
    at org.infinispan.interceptors.base.CommandInterceptor.handleDefault(CommandInterceptor.java:130)
    at org.infinispan.commands.AbstractVisitor.visitPrepareCommand(AbstractVisitor.java:126)
    at org.infinispan.commands.tx.PrepareCommand.acceptVisitor(PrepareCommand.java:133)
    at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116)
    at org.infinispan.interceptors.EntryWrappingInterceptor.visitPrepareCommand(EntryWrappingInterceptor.java:93)
    at org.infinispan.commands.tx.PrepareCommand.acceptVisitor(PrepareCommand.java:133)
    at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116)
    at org.infinispan.interceptors.locking.AbstractTxLockingInterceptor.invokeNextAndCommitIf1Pc(AbstractTxLockingInterceptor.java:120)
    at org.infinispan.interceptors.locking.OptimisticLockingInterceptor.visitPrepareCommand(OptimisticLockingInterceptor.java:131)
    at org.infinispan.commands.tx.PrepareCommand.acceptVisitor(PrepareCommand.java:133)
    at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116)
    at org.infinispan.interceptors.NotificationInterceptor.visitPrepareCommand(NotificationInterceptor.java:58)
    at org.infinispan.commands.tx.PrepareCommand.acceptVisitor(PrepareCommand.java:133)
    at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116)
    at org.infinispan.interceptors.TxInterceptor.visitPrepareCommand(TxInterceptor.java:106)
    at org.infinispan.commands.tx.PrepareCommand.acceptVisitor(PrepareCommand.java:133)
    at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116)
    at org.infinispan.interceptors.StateTransferLockInterceptor.handleWithRetries(StateTransferLockInterceptor.java:213)
    at org.infinispan.interceptors.StateTransferLockInterceptor.visitPrepareCommand(StateTransferLockInterceptor.java:85)
    at org.infinispan.commands.tx.PrepareCommand.acceptVisitor(PrepareCommand.java:133)
    at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116)
    at org.infinispan.interceptors.base.CommandInterceptor.handleDefault(CommandInterceptor.java:130)
    at org.infinispan.commands.AbstractVisitor.visitPrepareCommand(AbstractVisitor.java:126)
    at org.infinispan.commands.tx.PrepareCommand.acceptVisitor(PrepareCommand.java:133)
    at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116)
    at org.infinispan.interceptors.InvocationContextInterceptor.handleAll(InvocationContextInterceptor.java:132)
    at org.infinispan.interceptors.InvocationContextInterceptor.handleDefault(InvocationContextInterceptor.java:91)
    at org.infinispan.commands.AbstractVisitor.visitPrepareCommand(AbstractVisitor.java:126)
    at org.infinispan.commands.tx.PrepareCommand.acceptVisitor(PrepareCommand.java:133)
    at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116)
    at org.infinispan.interceptors.BatchingInterceptor.handleDefault(BatchingInterceptor.java:86)
    at org.infinispan.commands.AbstractVisitor.visitPrepareCommand(AbstractVisitor.java:126)
    at org.infinispan.commands.tx.PrepareCommand.acceptVisitor(PrepareCommand.java:133)
    at org.infinispan.interceptors.InterceptorChain.invoke(InterceptorChain.java:345)
    at org.infinispan.transaction.TransactionCoordinator.commit(TransactionCoordinator.java:174)
    at org.infinispan.transaction.synchronization.SynchronizationAdapter.afterCompletion(SynchronizationAdapter.java:81)
    at org.infinispan.transaction.tm.DummyTransaction.notifyAfterCompletion(DummyTransaction.java:285)
    at org.infinispan.transaction.tm.DummyTransaction.runCommitTx(DummyTransaction.java:334)
    at org.infinispan.transaction.tm.DummyTransaction.commit(DummyTransaction.java:91)
    at org.infinispan.transaction.tm.DummyBaseTransactionManager.commit(DummyBaseTransactionManager.java:102)
    at org.jboss.as.clustering.web.impl.TransactionBatchingManager.endBatch(TransactionBatchingManager.java:75)
    at org.jboss.as.web.session.DistributableSessionManager.processSessionRepl(DistributableSessionManager.java:1515) [jboss-as-web-7.1.3.Final-redhat-4.jar:7.1.3.Final-redhat-4]
    at org.jboss.as.web.session.DistributableSessionManager.storeSession(DistributableSessionManager.java:857) [jboss-as-web-7.1.3.Final-redhat-4.jar:7.1.3.Final-redhat-4]
    at org.jboss.as.web.session.InstantSnapshotManager.snapshot(InstantSnapshotManager.java:47) [jboss-as-web-7.1.3.Final-redhat-4.jar:7.1.3.Final-redhat-4]
    at org.jboss.as.web.session.ClusteredSessionValve.handleRequest(ClusteredSessionValve.java:142) [jboss-as-web-7.1.3.Final-redhat-4.jar:7.1.3.Final-redhat-4]
    at org.jboss.as.web.session.ClusteredSessionValve.invoke(ClusteredSessionValve.java:99) [jboss-as-web-7.1.3.Final-redhat-4.jar:7.1.3.Final-redhat-4]
    at org.jboss.as.web.session.JvmRouteValve.invoke(JvmRouteValve.java:92) [jboss-as-web-7.1.3.Final-redhat-4.jar:7.1.3.Final-redhat-4]
    at org.jboss.as.web.session.LockingValve.invoke(LockingValve.java:64) [jboss-as-web-7.1.3.Final-redhat-4.jar:7.1.3.Final-redhat-4]
    at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169) [jboss-as-web-7.1.3.Final-redhat-4.jar:7.1.3.Final-redhat-4]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.17.Final-redhat-1.jar:]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.17.Final-redhat-1.jar:]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.17.Final-redhat-1.jar:]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:372) [jbossweb-7.0.17.Final-redhat-1.jar:]
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.17.Final-redhat-1.jar:]
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:679) [jbossweb-7.0.17.Final-redhat-1.jar:]
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:931) [jbossweb-7.0.17.Final-redhat-1.jar:]
    at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_05]
Caused by: java.lang.RuntimeException: Failure to marshal argument(s)
    at org.infinispan.remoting.transport.jgroups.CommandAwareRpcDispatcher.marshallCall(CommandAwareRpcDispatcher.java:257)
    at org.infinispan.remoting.transport.jgroups.CommandAwareRpcDispatcher.processSingleCall(CommandAwareRpcDispatcher.java:274)
    at org.infinispan.remoting.transport.jgroups.CommandAwareRpcDispatcher.invokeRemoteCommand(CommandAwareRpcDispatcher.java:165)
    ... 72 more
Caused by: org.infinispan.marshall.NotSerializableException: javax.naming.InitialContext
Caused by: an exception which occurred:
    in field ctx
    in object java.util.HashMap@f297a789
    in object org.jboss.as.clustering.SimpleMarshalledValue@f297a789
    in object org.infinispan.atomic.PutOperation@7310a7f7
    in object java.util.LinkedList@fbc0fbb9
    in object org.infinispan.atomic.AtomicHashMapDelta@74047c30
    in object org.infinispan.commands.write.PutKeyValueCommand@ee8a1922
    in object org.infinispan.commands.tx.PrepareCommand@2de5c5a6

Resolution

  • Make sure that the data which an application is trying to store inside the HttpSession is marked as "java.io.Serializable"
  • The above error clearly indicates that the Application is trying to Store the "javax.naming.InitialContext" inside the HttpSession as following:
FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("something", ctx);
OR
httpSession.setAttribute("something",ctx);
  • As "javax.naming.InitialContext" class is not marked as "java.io.Serializable" thats why The Infinispan cache is throwing the mentioned error while storing the value inside the Infinispan cache.
  • So application developers need to check the application code to find out which class contains a "javax.naming.InitialContext" Variable with name "ctx" which application is trying to store inside the HttpSession.
  • If application is using JSF then check the ManagedBean which might be using @SessionScoped annotation and might be also declaring "InitialContext ctx" variable in that class. Which can be either declared as "transient" so that will not be used at the time of serialization.

Root Cause

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.