2 Replies Latest reply on Oct 8, 2007 5:01 AM by umberto_soprano

    Transaction not rolling back in CONTAINER mode

    umberto_soprano

      Hello,
      I've a EHB3 Stateless bean who's using direct JDBC connections (no persistence manager) to store data in a database.

      If I try to use TransactionManagement=CONTAINER Jboss seems to not execute roll backs in case of exceptions (both Application or Runtime exception). I inserted an as hoc thrown Exception to simulate the fault.
      Managing TransactionManagement=BEAN works.

      Any suggestion (code example below)?

      CONTAINER mode (no rollback):

      
      @Stateless
      @javax.ejb.ApplicationException(rollback = true)
      @TransactionManagement(TransactionManagementType.CONTAINER)
      public class x implements y,z{
      
      @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
      public Message processMessage() throws Exception
      {
      
      try {
       <<insert to DB>>
       << launch Exception>>
      } catch (Exception e1)
      {
       <<log>>
       throw e1;
      }}
      
      


      BEAN mode (rollback executed):

      
      @Stateless
      @javax.ejb.ApplicationException(rollback = true)
      @TransactionManagement(TransactionManagementType.CONTAINER)
      public class x implements y,z{
      
      @Resource
      private UserTransaction utx;
      
      @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
      public Message processMessage() throws Exception
      {
      
      try {
       utx.begin();
       <<insert to DB>>
       << launch Exception>>
       utx.commit();
      } catch (Exception e1)
      {
       utx.rollback();
       <<log>>
       throw e1;
      }}