XA Rollback against JDBC database due to SQL constraint violation gives exception "XA error code: -3".
Issue
We are using XA transaction and writing data to a JDBC database.
The XA transaction is supposed to rollback when we have an SQL constraint violation (SQL exception). However the XA rollback fails with
Error ending association for XAResource
org.apache.geronimo.transaction.manager.WrapperNamedXAResource@57946cc8;
transaction will roll back. XA error code: -3
javax.transaction.xa.XAException: com.microsoft.sqlserver.jdbc.SQLServerException:
The connection is closed.
The relevant parts in the log file read:
WARN | GeronimoConnectionEventListener | 119 - org.apache.aries.transaction.jdbc - 1.0.1.redhat-610394 | connectionErrorOccurred called with null com.microsoft.sqlserver.jdbc.SQLServerException: Violation of UNIQUE KEY constraint 'UQ__TBL_Some__8F7960A3DE1089C2'. Cannot insert duplicate key in object
XXX.Something'. The duplicate key value is (Text).
INFO | SinglePoolConnectionInterceptor | 119 - org.apache.aries.transaction.jdbc - 1.0.1.redhat-610394 | Removing ManagedConnectionInfo: org.apache.geronimo.connector.outbound.ManagedConnectionInfo@334f20e6. mc: org.tranql.connector.jdbc.ManagedXAConnection@ff8f65b] from pool org.apache.geronimo.connector.outbound.SinglePoolConnectionInterceptor@21f5d88e
WARN | SqlExceptionHelper | 270 - org.jboss.logging.jboss-logging - 3.1.4.GA | SQL Error: 2627, SQLState: 23000
ERROR | SqlExceptionHelper | 270 - org.jboss.logging.jboss-logging - 3.1.4.GA | Violation of UNIQUE KEY constraint XXX__8F7960A3DE1089C2'. Cannot insert duplicate key in object 'XXX.Something'. The duplicate key value is (Text).
WARN | Transaction | 117 - org.apache.aries.transaction.manager - 1.0.1.redhat-610394 | Error ending association for XAResource org.apache.geronimo.transaction.manager.WrapperNamedXAResource@57946cc8; transaction will roll back. XA error code: -3 javax.transaction.xa.XAException: com.microsoft.sqlserver.jdbc.SQLServerException: The connection is closed.
Environment
- JBoss Fuse 6.1
- Using XA transactions and Aries transaction manager
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
