9 Replies Latest reply on Mar 27, 2002 7:21 PM by oravecz

    My error caught, TransactionRolledBackException thrown



      I'm using JBoss 2.4.4/tomcat; I open a UserTransaction at the servlet (and later commit or rollback it there). My EJBs use container-managed transaction so the transaction that the servlet opened works for me, inside the EJB.

      This all works okay, however, I have an annoying problem:
      1. I throw an Error from within the EJB
      2. The EJBContainer catches it and rolls back the transaction (okay so far)
      3. The EJBContainer throws a TransactionRolledBackException.

      The problem ofcourse is in the last step of this process - I want my error to be thrown, not TransactionRolledBackException! The TransactionRolledBackException doesn't even let me get to the nested exception or anything like that, which means I can't get to my error message!

      So, my questions are:
      1. Is there any way to disable throwing the TransactionRolledBackException? At the servlet level I will be well aware of the fact that the transaction should be rolled back.
      2. To avoid this problem, I thought I can close the UserTransaction before throwing the error, thus eliminating the rollback at the EJBContainer. However, I tried resolving "java:comp/UserTransaction" in the JNDI, and it said it is not bound. The same name was bound when trying from the servlet, so I don't know why can't I get to it from the EJB. I don't have access to the EJBContext so I'd really like to find it in JNDI.