Weblogic JTA : Getting Root Cause of UnexpectedRollbackException

If JPA is used with hibernate, spring and application is hosted in weblogic with JTA, the runtime exceptions thrown from DB is eaten up and wrapped with UnexpectedRollbackException, which is totally misleading. Most of the time the exceptions are caused by DB constraint violations.

The see the actual cause, the following line should be added to the weblogic file bin/setDomainEnv.sh:

JAVA_OPTIONS="${JAVA_OPTIONS} -Dweblogic.transaction.allowOverrideSetRollbackReason=true"

If you are using windows, add the following line to the /bin/setDomainEnv.cmd:

set JAVA_OPTIONS=%JAVA_OPTIONS% -Dweblogic.transaction.allowOverrideSetRollbackReason=true

Happy debugging 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s