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: HEAD
Reporter: Olaf Fricke
Priority: Blocker
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