Jay SenSharma

Jay SenSharma

Sometimes we get “The XID is not valid” error while Using Oracle XA-DataSource. We will discuss why we get this kind of wrror and how to aviod it.

java.sql.SQLException: XA error: XAER_NOTA : The XID is not valid start() failed on resource ‘weblogic.jdbc.jta.DataSource’: XAER_NOTA : The XID is not valid

at oracle.jdbc.xa.OracleXAResource.checkError(OracleXAResource.java:

According to XA protocol it requires that all the SQL statements for one and the same transaction branch be issued between an xa_start() and an xa_end() call.
In case of a distributed transaction, Every individual database represents one XAResource that will have one transaction branch in one distributed transaction. Now the WebLogic Server transaction manager considers every JDBC DataSource as a separate XAResource, which means it cannot evaluate if different connection pools or data sources point to the same database.

WLS makes takes care that every call to one XAResource has the correct sequence of calls: xa_start, sql statements, and xa_end. even  WebLogic Server represents a multi-threading system, where different operations occur in a highly parallel environment. So the calls to different XAResources like JDBC connection pools will happen concurrently. If two XA-Resources are defined for the same database, nested xa_start – xa_end pairs may result.

Example: Suppose if there are two DataSources involved in one Transaction, then the  calls sequence will be something as  following:

xa_start to for DataSource ———->PoolA
Executing SQL Statements for DataSource ———->PoolA
xa_start(Joining PoolB) for DataSource ———->PoolB
Executing SQL Statements for DataSource ———->PoolA
Executing SQL Statements for DataSource———->PoolB
xa_end() for DataSource ———->PoolB
xa_end() for DataSource ———->PoolA

Everything is fine until “poolA” and “poolB” are different databases and It Means Different Resource Managers will take part in this Complete Transaction flow.
BUT The Problem arises when poolA and poolB point to the same Oracle database.

It is similar to Oracle BUG: 3094138.995

Also try the following workaround:

If you have only one DataSource …. Still if you observe the above issue then …try the below option:

For the JDBC Connection Pools to set the XASetTransactionTimeout to true and XATransactionTimeout to zero (“When this parameter is set to zero, the XAResource Session Timeout will be set to the global transaction timeout.”)




Jay SenSharma

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.