4 Replies Latest reply on Apr 19, 2004 9:04 PM by Adrian Brock

    javax.transaction.Synchronization

    Patrick Linskey Newbie

      Hello,

      I recently discovered that JBoss does not use the javax.transaction.Synchronization interface in the way that I expected.

      I work for a company that makes a Java Data Objects implementation, and we recently received a report of an unexpected commit happening when a RemoteException was thrown from a session bean, forcing a rollback. The problem was that our JDO implementation was flushing data to the data store in Synchronization.beforeCompletion(), which JBoss 3.0.0RC1 evidently invokes before rollbacks as well as before commits.

      My interpretation of the Synchronization interface (based on Sun's JavaDoc (http://java.sun.com/products/jta/javadocs-1.0.1) is that beforeCompletion() is invoked before a transaction is committed. However, empirical evidence seems to indicate that JBoss is invoking beforeCompletion regardless of whether the transaction is being rolled back or committed.

      Is there anyone out there that can convince me that the JBoss behavior is correct?


      -Patrick Linskey

        • 1. Re: javax.transaction.Synchronization
          Sri Krishna Newbie

          The spec I believe says that the beforeCompletion() call does not have to be called if a tx is rolled back. Hence the behavior is correct though, may be unusual.

          • 2. Re: javax.transaction.Synchronization
            tomdavies Newbie

            I think you are mistaken.

            The spec says:

            The Synchronization.beforeCompletion method is called prior to the start
            of the two-phase transaction commit process. This call is executed with the
            transaction context of the transaction that is being committed.


            so calling beforeCompletion during rollback seems completely wrong, although afterCompletion should be called after a rollback.

            The current (3.2.4RC1) JBoss behaviour is wrong, IMHO.

            Tom

            • 3. Re: javax.transaction.Synchronization
              tomdavies Newbie

              Just to make things clearer, here's a snippet of stack trace:

               at kodo.runtime.PersistenceManagerImpl.beforeCompletion(PersistenceManagerImpl.java:650)
              
               at org.jboss.tm.TransactionImpl.doBeforeCompletion(TransactionImpl.java:1308)
              
               at org.jboss.tm.TransactionImpl.rollback(TransactionImpl.java:456)
              
               at org.jboss.ejb.plugins.TxInterceptorCMT.endTransaction(TxInterceptorCMT.java:436)
              
               at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:323)
              
               at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:147)
              
               at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:118)
              
               at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
              
               at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
              
               at org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessionContainer.java:331)
              
               at org.jboss.ejb.Container.invoke(Container.java:713)
              


              PersistenceManagerImpl implements javax.transaction.Synchronization.

              • 4. Re: javax.transaction.Synchronization
                Adrian Brock Master

                You are correct, it is not correct.
                It has already been fixed in JBoss4 but the fix has not been backported yet.