How can I determine why JPA/eclipselink/J2EE is issuing a ROLLBACK to the DB?
I am chasing a problem where I see SQL statements run in my database log in a transaction, then see that transaction rolledback.
This happens on both Oracle and Postgres, but only on some installations. The application itself is a pretty standard J2EE application using JPA and Eclipselink.
I am not seeing any exceptions, nor is the code explicitly giving up and rolling back.
The best I have been able to do so far is find this log statement:
[#|2011-09-26T11:30:56.052-0700|FINER|sun-appserver2.1|org.eclipse.persistence.session.file:/opt/glassfish/domains/domain1/applications/j2ee-apps/myapp/myapp-ejb_jar/_myapp-ejbPU.transaction|_ThreadID=18;_ThreadName=httpSSLWorkerThread-8888-2;ClassName=null;MethodName=null;_RequestID=e78196
09-bf2e-4026-8cbb-87fdd047c5eb;|begin unit of work flush|#]
It occurs at the exact same time as the ROLLBACK in the postgres log:
appuser @ dbname: 102012/7/67486 2011-09-26 18:30:56.052 UTC - LOG: execute S_3: ROLLBACK
Note that the DB is on UTC while the application is on Pacific.
The relevant code is being called using a webservice with @TransactionAttribut开发者_如何转开发e(TransactionAttributeType.SUPPORTS)
I am working with both logging levels and the debugger to see if I can find an exception being thrown and swallowed that might cause this.
How can I find out what code is causing the rollback?
You can enable logging on finest with EclipseLink to debug the issue. Any exception that occurred within EclipseLink will be logged.
See, http://wiki.eclipse.org/EclipseLink/Examples/JPA/Logging
Also ensure you are not throwing an error to cause your SessionBean to rollback.
精彩评论