I have a problem with my XA Transaction.
If you look at the picture, the XA Transaction flow order is numbered. The call number 3
is the half-workaround I have found so far to half-solve the problem. I mean, if I don't make the SELECT 1
query to Database 2
before accesing the ejb 2, the Transaction fails.
I say half-solves the problem, because when I put the SELECT 1
query, the Servlet doesn't crash and I can complete the Transaction. But this workaround is not applicable in other scenarios where for example an external B2B client don't have and shouldn't have access to our internal Database 2
, so they can't make the SELECT 1
query to fix it.
The concrete exception point is in the Hibernate beforeComplete
Synchronization
. It crashes when Hibernate is flushing cache to Database 2
but Oracle throws this error:
ORA-02051: another session or branch in same transaction failed or finalized
After spending days making proves and reading the OMG "Transaction Service Specification" and chapter 10 of the book "Mastering EJB" i cannot understand why my XA Transaction fails ;)
I Would be very grateful if someone can help me in either way.
The Full stack trace is this:
> 2014-11-11 18:27:27,365 DEBUG [ORB.thread.pool : 0] [LogicalConnectionImpl] [f59d55f3-8361-4c80-975c-8df36f89b7c3] Obtained JDBC connection
2014-11-11 18:27:27,428 DEBUG [ORB.thread.pool : 0] [SqlExceptionHelper] [f59d55f3-8361-4c80-975c-8df36f89b7c3] could not execute statement [n/a]
java.sql.SQLSyntaxErrorException: ORA-02051: otra sesi?? bifurcaci??ha fallado o terminado en la misma transacci??
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:445)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:879)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:450)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:192)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:531)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:207)
at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:1044)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1329)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3584)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3665)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeUpdate(OraclePreparedStatementWrapper.java:1352)
at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.pmiExecuteUpdate(WSJdbcPreparedStatement.java:1185)
at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.executeUpdate(WSJdbcPreparedStatement.java:802)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:186)
at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:58)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3079)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3521)
at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:88)
at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:393)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:385)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:301)
at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:349)
at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:56)
at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1159)
at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:404)
at org.hibernate.engine.transaction.synchronization.internal.SynchronizationCallbackCoordinatorNonTrackingImpl.beforeCompletion(SynchronizationCallbackCoordinatorNonTrackingImpl.java:106)
at org.hibernate.engine.transaction.synchronization.internal.RegisteredSynchronization.beforeCompletion(RegisteredSynchronization.java:53)
at com.ibm.ws.uow.ComponentContextSynchronizationWrapper.beforeCompletion(ComponentContextSynchronizationWrapper.java:65)
at com.ibm.tx.jta.impl.RegisteredSyncs.coreDistributeBefore(RegisteredSyncs.java:291)
at com.ibm.ws.tx.jta.RegisteredSyncs.distributeBefore(RegisteredSyncs.java:153)
at com.ibm.ws.tx.jta.TransactionImpl.prePrepare(TransactionImpl.java:2339)
at com.ibm.tx.jta.impl.TransactionImpl.internalPrepare(TransactionImpl.java:1422)
at com.ibm.ws.Transaction.JTS.TransactionWrapper.prepare(TransactionWrapper.java:204)
at com.ibm.ws.Transaction.JTS.WSCoordinatorImpl.prepare(WSCoordinatorImpl.java:144)
at com.ibm.ws.Transaction.JTS._WSCoordinatorImplBase._invoke(_WSCoordinatorImplBase.java:50)
at com.ibm.CORBA.iiop.ServerDelegate.dispatchInvokeHandler(ServerDelegate.java:669)
at com.ibm.CORBA.iiop.ServerDelegate.dispatch(ServerDelegate.java:523)
at com.ibm.rmi.iiop.ORB.process(ORB.java:523)
at com.ibm.CORBA.iiop.ORB.process(ORB.java:1575)
at com.ibm.rmi.iiop.Connection.doRequestWork(Connection.java:3039)
at com.ibm.rmi.iiop.Connection.doWork(Connection.java:2922)
at com.ibm.rmi.iiop.WorkUnitImpl.doWork(WorkUnitImpl.java:64)
at com.ibm.ejs.oa.pool.PooledThread.run(ThreadPool.java:118)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1815)
UPDATE:
Same use case WORKS FINE on Wildfly attacking either an Oracle Database Server, Oracle XE or Postgresql. So it seams it's a WAS problem. What do you think?