5 Replies Latest reply on Aug 16, 2010 1:17 PM by mbasnight

    @Transactional not being honored

    mbasnight

      I have set up JPA with a JTA TX Mgr (Geronimo, fusesource.com's servicemix TX mgr). The TX mgr is exposed via a osgi:reference. Im using Extended PC's. These are being injected (properly) into my Repository code, but when i throw a exception, i dont see the rollback happen down to the database. My camel route thats processing this does in fact rollback. Its marked as transacted(). Ive been wading thru spring tx and spring aop to see whats happening but so far im at a loss. Below is my configuration & code.

       

      It is interesting to note that it does in fact save the data to the database, and the rollback does not take place. I assume there is some transaction going on there behind the scenes. It is also interesting to note that NO TX advice works, neither in aop advice or xmlns:tx. I went so far to mark TX's as readonly and data still saves. I have also included the debug logs from servicemix regarding the spring and hibernate code. I also made sure the Repository was a prototype as per the javadoc.

       

      Any help would be appreciated!

       

      Below is the output from the DEBUG output of servicemix 4.2.0 fuse 02-00.

       

      Edited by: mbasnight on Aug 11, 2010 5:52 PM - removed the debug and put into a attachment named output.txt

        • 1. Re: @Transactional not being honored
          mbasnight

          So i have debugged down to the spring proxy creation for the prototype bean (JTAPersonRepository), and i have verified that this bean is Advised (spring-aop) has a Transaction Source Advisor. The TX Source Advisorhas the proper TX Mgr (GeronimoTXMgr) attached to it. Its txAttributeSource is also AnnotationTX Source, so its definitely working as of creation. Debugging to continue.

           

          If anyone out there in fuse-land has been down this rabbit hole, any advise would be well received.

          • 2. Re: @Transactional not being honored
            mbasnight

            A TransactionInterceptor is in fact being called thru cglib. Ive verified thru camel that the appropriate method on my "bean:beanName?method=name", and the proxy has TX Advice attached to it. The TX manager is called before the method is invoked.

             

            Ill keep diagnosing thru the exception thrown to see why its not being rolled back in that database.

            • 3. Re: @Transactional not being honored
              mbasnight

              I have also verified my database supports transactions. My table is Innodb. I have also enabled the query logs for mysql, and i see autocommit=1 being set. Will look into this more.

              • 4. Re: @Transactional not being honored
                mbasnight

                Now the spring support AbstractPlatform TX Mgr is setting my TX as TransactionSynchronization.STATUS_ROLLED_BACK. This is a good thing! im getting closer to finding out why this is happening.

                • 5. Re: @Transactional not being honored
                  mbasnight

                  Ok it looks as if i had not figured the last step of the process. JCA. With Jencks configured as my XA DS provider, i dont even need the MysqlXADatasource!! Super simple setup. Hope this helps someone in the future!!

                   

                  http://docs.codehaus.org/display/JCA/Outbound+JDBC