Support Article
IllegalResourceIn2PCTransactionException on external datasource
SA-12486
Summary
Initially the application was connected to an external database by giving the complete JDBC string with credentials in the database rule itself. This is changed by adding a new datasource at websphere level. After this change, system throws database errors.
Error Messages
Caused by:
java.sql.SQLException: enlist: caught Exception
at com.ibm.ws.rsadapter.AdapterUtil.toSQLException(AdapterUtil.java:1543)
at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.beginTransactionIfNecessary(WSJdbcConnection.java:779)
at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.prepareStatement(WSJdbcConnection.java:2745)
at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.prepareStatement(WSJdbcConnection.java:2698)
at com.pega.pegarules.data.internal.access.DatabaseConnectionImpl.prepareStatement(DatabaseConnectionImpl.java:429)
at com.pega.pegarules.data.internal.access.ConnectionStatementStore.prepareStatement(ConnectionStatementStore.java:111)
at com.pega.pegarules.data.internal.access.Saver.saveNewInstanceWithNoDeletedColumnNotOnlyIfNew(Saver.java:1067)
... 61 more
Caused by:
javax.resource.ResourceException: enlist: caught Exception
at javax.resource.ResourceException.<init>(ResourceException.java:80)
at com.ibm.ejs.j2c.LocalTransactionWrapper.enlist(LocalTransactionWrapper.java:563)
at com.ibm.ejs.j2c.ConnectionManager.lazyEnlist(ConnectionManager.java:2186)
at com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl.lazyEnlist(WSRdbManagedConnectionImpl.java:2569)
at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.beginTransactionIfNecessary(WSJdbcConnection.java:714)
... 66 more
Caused by:
com.ibm.ws.Transaction.IllegalResourceIn2PCTransactionException: Illegal attempt to enlist multiple 1PC XAResources
at com.ibm.ws.tx.jta.RegisteredResources.enlistResource(RegisteredResources.java:864)
at com.ibm.ws.tx.jta.TransactionImpl.enlistResource(TransactionImpl.java:1781)
at com.ibm.ws.tx.jta.TranManagerSet.enlistOnePhase(TranManagerSet.java:612)
at com.ibm.ejs.j2c.LocalTransactionWrapper.enlist(LocalTransactionWrapper.java:593)
... 69 more
Steps to Reproduce
Run an activity that saves to both a table in an external database and to a PegaRULES table with a single commit statement at the end.
Root Cause
The root cause of this problem is defect/misconfiguration in the operating environment. Since there are two datasources involved, WebSphere treats it like a global transaction and requires that atleast one of the datasources to not use an XA driver. If you do not want to have both of the database operations in the same global transaction then commit the first transaction before saving the second.
Resolution
This issue is resolved through the following local-change:
Add a commit statement after each Obj-Save in the activity.
Published July 30, 2015 - Updated October 8, 2020
Have a question? Get answers now.
Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.