I have a JUnit test that calls a helper class method to do some stuff. In the helper class some EJB2s are called that perform Hibernate inserts and reads.
The work is done in a UserTransaction and when at the end commit() is called a weblogic.transaction.internal.AppSetRollbackOnlyException is thrown with as cause "weblogic.transaction.RollbackException: Unknown reason"
Any idea what goes wrong?
JUnit test:
Code:
public void testSynchronize() throws SystemException, NotSupportedException, SecurityException, IllegalStateException, RollbackException, HeuristicMixedException, HeuristicRollbackException {
transaction = (UserTransaction) JNDIHelper.getInstance().lookup("javax.transaction.UserTransaction");
transaction.setTransactionTimeout(3600);
transaction.begin();
synchronizationHelper = new SynchronizationHelper();
synchronizationHelper.synchronize(false);
transaction.commit(); // here I get the exception
}
Last lines of the Weblogic log:
Code:
17:58:17,481 DEBUG org.hibernate.jdbc.JDBCContext:228 - before transaction completion
17:58:17,481 DEBUG org.hibernate.impl.SessionImpl:421 - before transaction completion
17:58:17,544 DEBUG org.hibernate.transaction.CacheSynchronization:114 - transaction after completion callback, status: 4
17:58:17,559 DEBUG org.hibernate.jdbc.JDBCContext:242 - after transaction completion
17:58:17,559 DEBUG org.hibernate.impl.SessionImpl:450 - after transaction completion
17:58:17,559 DEBUG org.hibernate.transaction.CacheSynchronization:121 - automatically closing session
17:58:17,559 DEBUG org.hibernate.impl.SessionImpl:381 - automatically closing session
17:58:17,559 DEBUG org.hibernate.impl.SessionImpl:301 - closing session
17:58:17,559 DEBUG org.hibernate.jdbc.ConnectionManager:398 - connection already null in cleanup : no action
Stacktrace:
Code:
-------------------------------------------------------------------------------
Test set: com.jnj.gtsc.usermanagement.helpers.SynchronizationHelperTest
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 275.476 sec <<< FAILURE!
testSynchronize(com.jnj.gtsc.usermanagement.helpers.SynchronizationHelperTest) Time elapsed: 275.304 sec <<< ERROR!
weblogic.transaction.internal.AppSetRollbackOnlyException
at weblogic.transaction.internal.TransactionImpl.setRollbackOnly(TransactionImpl.java:508)
at org.hibernate.transaction.CacheSynchronization.setRollbackOnly(CacheSynchronization.java:102)
at org.hibernate.transaction.CacheSynchronization.beforeCompletion(CacheSynchronization.java:92)
at weblogic.transaction.internal.ServerSCInfo.callBeforeCompletions(ServerSCInfo.java:1069)
at weblogic.transaction.internal.ServerSCInfo.startPrePrepareAndChain(ServerSCInfo.java:118)
at weblogic.transaction.internal.ServerTransactionImpl.localPrePrepareAndChain(ServerTransactionImpl.java:1202)
at weblogic.transaction.internal.ServerTransactionImpl.globalPrePrepare(ServerTransactionImpl.java:2007)
at weblogic.transaction.internal.ServerTransactionImpl.internalCommit(ServerTransactionImpl.java:257)
at weblogic.transaction.internal.ServerTransactionImpl.commit(ServerTransactionImpl.java:228)
at weblogic.transaction.internal.CoordinatorImpl.commit(CoordinatorImpl.java:82)
at weblogic.transaction.internal.CoordinatorImpl_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:491)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:434)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:429)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:35)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)
--------------- nested within: ------------------
weblogic.transaction.RollbackException: Unknown reason - with nested exception:
[weblogic.transaction.internal.AppSetRollbackOnlyException]
at weblogic.rjvm.BasicOutboundRequest.sendReceive(BasicOutboundRequest.java:108)
at weblogic.rmi.internal.BasicRemoteRef.invoke(BasicRemoteRef.java:164)
at weblogic.transaction.internal.CoordinatorImpl_816_WLStub.commit(Unknown Source)
at weblogic.transaction.internal.TransactionImpl.commit(TransactionImpl.java:309)
at weblogic.transaction.internal.TransactionManagerImpl.commit(TransactionManagerImpl.java:303)
at weblogic.transaction.internal.TransactionManagerImpl.commit(TransactionManagerImpl.java:296)
at com.jnj.gtsc.usermanagement.helpers.SynchronizationHelperTest.testSynchronize(SynchronizationHelperTest.java:115)
Caused by: weblogic.transaction.RollbackException: Unknown reason
at weblogic.transaction.internal.TransactionImpl.throwRollbackException(TransactionImpl.java:1687)
at weblogic.transaction.internal.ServerTransactionImpl.internalCommit(ServerTransactionImpl.java:311)
at weblogic.transaction.internal.ServerTransactionImpl.commit(ServerTransactionImpl.java:228)
at weblogic.transaction.internal.CoordinatorImpl.commit(CoordinatorImpl.java:82)
at weblogic.transaction.internal.CoordinatorImpl_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:491)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:434)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:429)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:35)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)