3 Replies Latest reply on Mar 29, 2005 1:54 AM by Bela Ban

    How do I get rollback to occur with remote cache access?

    jlmcknight Newbie

      I have JbossCache 1.2.1 deployed on one Jboss instance (3.2.7) and I'm accessing it remotely from another Jboss instance. The client Jboss instance is running a stateless session bean with a container managed transaction, and is looking up the remote cache via JNDI.

      In testing this, I found that when I threw an EJBException after inserting data into the remote cache, the inserted data did not get rolled back. If the cache is deployed in the same Jboss instance, however, the cache rollback does occur.

      I also tried going through a stateless session bean on the Jboss instance with the cache, but the rollback still didn't occur when I threw an EJBException on the client Jboss instance.

      Is there something I need to do differently to get the remote cache rollback to occur, either with direct cache access or through another ejb, or is that not even possible?


        • 1. Re: How do I get rollback to occur with remote cache access?
          Bela Ban Master

          Maybe the remote cache was not enrolled in the TX, did you make sure that this was the case ?
          Also, try the following: call Transaction.setRollbackOnly() on top of throwing the exception and see whether the data on the remote cache is not removed when the TX rolls back.
          If this is still the case, can you create a simple test case and submit it in the form of a JIRA bug report (attach the test case). This would be really helpful to us !

          • 2. Re: How do I get rollback to occur with remote cache access?
            jlmcknight Newbie

            Thanks for the reply.

            I think I discovered for myself that the scenario I tried where there was a session bean running on the jboss instance with the cache wouldn't work because the JBoss transaction manager doesn't extend transactions across JVM's. However, from your reply, I assume it should work if the cache is looked up and accessed directly from the other instance.

            I apologize for my ignorance, but could you give me a little more guidance with your suggestions? I'm no expert on transactions, I've mostly just used container managed transactions without any direct manipulation.

            What exactly do I need to do to verify whether the cache was enrolled in the transaction?

            Also, I tried a sessionContext.setRollbackOnly() in my session bean, but that made no difference, the cache still didn't roll back. I was also going to try setting that on the transaction at the cache level, in case that's what you meant, so I tried to get the Transaction Manager for the cache using getTransactionManager() on the TreeCacheMBean instance, but that resulted in this error...

            Caused by: java.io.NotSerializableException: org.jboss.tm.TxManager
            at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1054)
            at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278)
            at java.rmi.MarshalledObject.(MarshalledObject.java:92)
            at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:364)

            • 3. Re: How do I get rollback to occur with remote cache access?
              Bela Ban Master

              I suggest debug the remote TreeCache MBean, set a breakpoint into TreeCache.put():
              public Object put(Fqn fqn, Object key, Object value) throws CacheException {
              GlobalTransaction tx=getCurrentTransaction();
              MethodCall m=new MethodCall(putKeyValMethodLocal, new Object[]{tx, fqn, key, value, Boolean.TRUE});
              return invokeMethod(m);

              Step into getCurrentTransaction(), you'll see that if getLocalTransaction() is null, then you don't have a TX.