Transactions in a replicated cache
jerrygauth Jan 27, 2006 4:21 PMI'm trying to cache several nodes within a transaction in a replicated cache environment. I'm using the latest JBossCache HEAD code along with a fairly recent build of JBossAS HEAD. The transaction is being executed from a servlet running on one of the cluster nodes.
If I use a non-replicated environment (e.g., INVALIDATION_SYNC), the transaction executes properly and commits or rolls back as expected.
If I use a replicated environment (e.g., REPL_SYNC), the transaction executes properly as long as I configure the cache to use the DummyTransactionManager and I use this manager to execute the transaction from the servlet.
If I get a transaction manager from JNDI (either java:TransactionManager or UserTransaction) and I configure my cache to use JBossTransactionManagerLookup, the transaction always fails during the prepare phase on the remote node. As noted, the same code works properly if the cache isn't replicated. I've attached the relevant stack trace.
I've looked for a JBossCache test that executes similarly (i.e., transaction in a replicated environment) but I've only been able to find one that executes in standalone mode using the dummy manager.
Any ideas on whether I'm missing something here?
ERROR [RpcDispatcher] failed invoking method
org.jboss.util.NestedRuntimeException: Already associated with a tx; - nested throwable: (java.lang.IllegalStateException: Already associated with a tx)
at org.jboss.cache.TreeCache.invokeMethod(TreeCache.java:4247)
at org.jboss.cache.TreeCache._replicate(TreeCache.java:3894)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jgroups.blocks.MethodCall.invoke(MethodCall.java:286)
at org.jgroups.blocks.RpcDispatcher.handle(RpcDispatcher.java:236)
at org.jgroups.blocks.RequestCorrelator.handleRequest(RequestCorrelator.java:618)
at org.jgroups.blocks.RequestCorrelator.receiveMessage(RequestCorrelator.java:515)
at org.jgroups.blocks.RequestCorrelator.receive(RequestCorrelator.java:326)
at org.jgroups.blocks.MessageDispatcher$ProtocolAdapter.handleUp(MessageDispatcher.java:734)
at org.jgroups.blocks.MessageDispatcher$ProtocolAdapter.access$300(MessageDispatcher.java:566)
at org.jgroups.blocks.MessageDispatcher$1.run(MessageDispatcher.java:703)
at java.lang.Thread.run(Thread.java:534)
Caused by: java.lang.IllegalStateException: Already associated with a tx
at org.jboss.tm.TxManager.resume(TxManager.java:660)
at org.jboss.cache.interceptors.TxInterceptor.handleRemotePrepare(TxInterceptor.java:263)
at org.jboss.cache.interceptors.TxInterceptor.invoke(TxInterceptor.java:124)
at org.jboss.cache.interceptors.Interceptor.invoke(Interceptor.java:67)
at org.jboss.cache.interceptors.CacheMgmtInterceptor.invoke(CacheMgmtInterceptor.java:128)
at org.jboss.cache.TreeCache.invokeMethod(TreeCache.java:4241)