views:

18

answers:

0

I recently migrated from JBoss4.x using ejb3 to JBoss5.x using ejb3.

When a runtime exception like NullPointerException is thrown, instead of the exception bubbling up so I can handle it via try-catch, I get an EJBTransactionRolledBackException instead which terminates the transaction without allowing me a chance to handle the error gracefully.This is new behavior in JBoss5 I believe which implements JEE more fully than Jboss4.x

Configuration: EJB3.1, JBoss5, ActiveMQ

javax.ejb.EJBTransactionRolledbackException: EntityManager must be access within a transaction

A hacky solution is to wrap the exception and throw a new one which seems to work. But I hate this approach since I lose the advantage of exceptions bubbling up to a top-level calling method that handles all runtime exceptions.

   try {
     -----
    } catch (Exception ex) {
        throw new Exception(ex);
    }

I already tried the solution mentioned in this thread but that did not seem to work. Anyone else encounter this problem?

http://stackoverflow.com/questions/3793649/why-session-bean-method-throw-ejbtransactionrolledbackexception-when-runtimeexcep