[jboss-jira] [JBoss JIRA] Closed: (EJBTHREE-1072) Ejb3TxPolicy does not rollback the transaction in case of an error

Alexey Loubyansky (JIRA) jira-events at lists.jboss.org
Wed Mar 12 10:24:59 EDT 2008


     [ http://jira.jboss.com/jira/browse/EJBTHREE-1072?page=all ]

Alexey Loubyansky closed EJBTHREE-1072.
---------------------------------------

    Resolution: Done

Fixed.
After I committed the test, there have been some change that made my test fail. So, ultimately, I had to fix the Ejb3TxPolicy as suggested. The tests for both container started tx and caller's tx are added to the txexceptions package.

> Ejb3TxPolicy does not rollback the transaction in case of an error
> ------------------------------------------------------------------
>
>                 Key: EJBTHREE-1072
>                 URL: http://jira.jboss.com/jira/browse/EJBTHREE-1072
>             Project: EJB 3.0
>          Issue Type: Bug
>    Affects Versions: AS 5.0.0.Beta3
>            Reporter: Olaf Fricke
>         Assigned To: Alexey Loubyansky
>            Priority: Critical
>             Fix For: AS 5.0.0.CR1
>
>
> The class Ejb3TxPolicy is used to rollback the transaction in the case of exceptions. According to the ejb 3.0 spec, the transaction is rolled back in case of ApplicationException with rollback() evaluating to true, in case of RuntimeExceptions or in case of EjbException. 
> All other exception will not lead to a rollback on the current transaction.
> Unfortunately, the same is true in case of errors. If, for example, an AssertionError (or a ClassDefNotFoundError etc.) occurs, the current transaction will be committed and not rolled back. This behaviour is wrong with respect to the ejb 3.0 spec (see for example table 14 on page 360 of ejbcore.pdf)
> A possible solution would be to wrap the error into a new RuntimeException after handling ApplicationException (in both methods handleExceptionInOurTx and handleInCallerTx):
> <code>
> if (t instanceof Error)
>       {
>          t = new RuntimeException(t);
>       }
> if (!(t instanceof RuntimeException || t instanceof RemoteException))
>       {
>          throw t;
>       }
> </code>
> The wrapping is necessary, because both the EJBException and the EJBTransactionRolledbackException can only handle exceptions, but not errors.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list