ORA-02051: another session or branch in same transaction failed or finalized in EAP 6

Solution Verified - Updated -

Issue

  • A single global transaction spans three nodes
  • Each node enlists an XA resource for an Oracle connection (each on a different branch of the global transaction)
  • Two of the three nodes complete their work and issue a prepare on their XA resources for the Oracle connections
  • The third node attempts to flush its Hibernate session using its XA resource and encounters an exception while issuing an execute against a PreparedStatement:
17:47:04,509 2014-05-22 ERROR [spi.SqlExceptionHelper] (EJB default - 5) () ORA-02051: another session or branch in same transaction failed or finalized
...
17:47:04,632 2014-05-22 TRACE [ats.jta] (EJB default - 5) () BaseTransaction.setRollbackOnly
...
Caused by: org.hibernate.exception.SQLGrammarException: could not execute statement
        at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:82)
        ...
        at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:136)
        ...
        at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:275)
        at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:328)
        at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:52)
        at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1233)
        at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:403)
        at org.hibernate.engine.transaction.synchronization.internal.SynchronizationCallbackCoordinatorImpl.beforeCompletion(SynchronizationCallbackCoordinatorImpl.java:112)
        ... 15 more
Caused by: java.sql.SQLSyntaxErrorException: ORA-02051: another session or branch in same transaction failed or finalized
        at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:439)
        ...
        at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:1008)
        ...
        at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeUpdate(OraclePreparedStatementWrapper.java:1350)
        at org.jboss.jca.adapters.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:493)
        at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:133)
        ... 27 more
  • The entire transaction is aborted as the result of the failure in the third node

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 7
    • 6
  • Oracle

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content