0 Replies Latest reply on May 5, 2016 7:49 AM by Allan Cheong

    JTA container managed transaction rollback not working for cxf jaxrs endpoint

    Allan Cheong Newbie

      Rest Endpoint

      <jaxrs:server id="jaxrs" address="">


                <ref component-id="service1" />



                <ref component-id="serviceX" />



                <ref component-id="runtimeExceptionMapper" />




      <route id="secureBridgeRoute">

           <from uri="jetty:;matchOnUriPrefix=true&amp;minThreads=8&amp;maxThreads=16" />

           <transacted ref="JTA_TRANSACTION" />

           <to uri="jetty:;throwExceptionOnFailure=false" />



      <bean id="dao1" class="com.example.Dao1" activation="eager">

           <jpa:context unitname="PU" property="entityManager" type="TRANSACTION" />


      Service bean

      <bean id="service1" class="com.example.Service1" activation="eager">

           <property name="dao1" ref="dao1" />

           <property name="dao2" ref="dao2" />

           <tx:transaction method="*" value="Required" />


      Service bean method pseudocode

      boolean create(entity1, entity2) {




      When dao2 persist failed, the transaction did not get rolled back. Entity1 is inserted into the DB.

      Additional information

      1) TransactionManager definition

      <reference id="platformTransactionManager" interface="org.springframework.transaction.PlatformTransactionManager" />

      <bean id="JTA_TRANSACTION" class="org.apache.camel.spring.spi.SpringTransactionPolicy">

           <property name="transactionManager" ref="platformTransactionManager" />

           <property name="propagationBehaviorName" value="PROPAGATION_REQUIRED" />


      2) My persistent unit is of type JTA and hibernate as the provider.

      3) I have an ExceptionMapper, which when I look into it, the stacktrace shows the transaction indeed is marked for rollback.

      4) The service beans are not separated to another bundle.

      I am wondering if:

      1. CXF OutFaultInterceptor has "eaten" the exception that is supposed to be caught by the container for transaction rollback. As a result, the rollback did not occur.
      2. The Entity Manager has to be the same instance shared amongst all DAOs for the rollback to happen.
      3. Could it be that I need to separate the service into another bundle?

      Appreciate if someone could let me know the correct approach on transaction handling at service layer for cxf jaxrs endpoint.


      Message was edited by: Allan Cheong