When setRollbackOnly() is Called in beforeCompletion() Synchronization Method , Thrown Exception Cannot be Obtained
(Doc ID 1547327.1)
Last updated on MARCH 27, 2023
Applies to:Oracle WebLogic Server - Version 126.96.36.199 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 behavior is to be able to obtain the thrown exception (embedded in TransactionRolledbackLocalException exception) from beforeCompletion() method .
To view full details, sign in with your My Oracle Support account.
Don't have a My Oracle Support account? Click to get started!
In this Document