Recently we had a problem with a broken transaction in an application running in Wildfly 20.
javax.persistence.TransactionRequiredException: WFLYJPA0060: Transaction is required to perform this operation (either use a transaction or extended persistence context)
We were not shure which line caused the exception, as the stacktrace was not very specific. So we debugged the application step by step and checked with the following code if the transaction was set to rollback or was still active:
As long as the status 1 (
ACTIVE) was returned the transaction was still valid, but at the subroutine the status switched to 4 (
We then could check what the exception was and change the Exception so that it does not rollback the transaction by annotating it with
@ApplicationException(rollback = false)
I Hope that this will help some of you when you encounter a broken transaction when debugging.
Thank you for reading!