When setRollbackOnly() is Called in beforeCompletion() Synchronization Method , Thrown Exception Cannot be Obtained
Last updated on NOVEMBER 05, 2016
Applies to:Oracle Weblogic Server - Version 220.127.116.11 and later
Information in this document applies to any platform.
Transaction manager supports synchronization mechanism.
This allows JPA providers (for instance EclipseLink or Hibernate) to be notified before and after a transaction completes
by registering a Synchronization object which implements javax.transaction.Synchronization Interface.
Here is a sample code showing how to register a Synchronization object (TestcaseJtaCallback) :
In beforeCompletion method , if an exception occurs, in the sample code above, the following treatment done is :
- rollback the transaction ( t.setRollbackOnly())
- and, throw the RollbackTestcaseException exception .
When invoking an EJB , if this Synchorization mechanism is used,
and if the setRollbackOnly () method is called in the beforeCompletion() method because of an error,
then the EJB caller will receive the javax.ejb.TransactionRolledbackLocalException exception .
The problem is that the exception which is thrown (RollbackTestcaseException) is not propagated :
the javax.ejb.TransactionRolledbackLocalException Exception, which is received by the EJB caller, does not
contain the exception cause (RollbackTestcaseException).
As a consequence , there is no way for the EJB caller to obtain the cause of the error which can happen in the beforeCompletion() method .
The expected behaviour is to be able to obtain the thrown exception (embedded in TransactionRolledbackLocalException exception) from beforeCompletion() method .
Sign In with your My Oracle Support account
Don't have a My Oracle Support account? Click to get started
Million Knowledge Articles and hundreds of Community platforms