6 Replies Latest reply on Aug 21, 2008 1:35 AM by Andrew Rubinger

    Rollback Tx on EJBException (NoSuchEJBException)?

    Andrew Rubinger Master

      EJB 3.0 Spec Reference is 14.4.2,

      I've got some failing tests on SFSB remove - the client expects a NoSuchEJBException, and the current Ejb3TxPolicy is wrapping it in a EJBTransactionRolledbackException before marking the Tx itself for rollback.

      I can make some of these tests pass with the patch below, though I can't derive from the spec whether or not EJBExceptions should warrant the Tx to be marked for rollback.

      Index: transactions/src/main/java/org/jboss/ejb3/tx/Ejb3TxPolicy.java
      --- transactions/src/main/java/org/jboss/ejb3/tx/Ejb3TxPolicy.java (revision 77044)
      +++ transactions/src/main/java/org/jboss/ejb3/tx/Ejb3TxPolicy.java (working copy)
      @@ -21,6 +21,7 @@
       package org.jboss.ejb3.tx;
      +import java.rmi.NoSuchObjectException;
       import java.rmi.RemoteException;
       import javax.ejb.ApplicationException;
      @@ -103,8 +104,14 @@
       t = new EJBTransactionRolledbackException(formatException("Unexpected Error", t));
      - else if(t instanceof RuntimeException || t instanceof RemoteException)
      + // If this is an EJBException, pass through to the caller
      + else if (t instanceof EJBException || t instanceof RemoteException)
      + // Leave Exception as-is (this is in place to handle specifically, and not
      + // as a generic RuntimeException
      + }
      + else if(t instanceof RuntimeException)
      + {
       t = new EJBTransactionRolledbackException(t.getMessage(), (Exception) t);
       else // application exception

      From what I can discern, the onus to continue/recover is a decision left to the client?