At some point, when WebLogic performs an XA operation, we will encounter the following error:
Java.sql.SQLException:Unexpected exception while enlisting xaconnection Java.sql.SQLException:XA error:XAER_NOTA:The XID is isn't valid start () failed on resource ' Weblogic.jdbc.jta.DataSource ': xaer_nota:the XID are not valid
Xaer_nota indicates that transaction branch does not exist at the ResourceManager end (DB,MQ, etc.). Does not exist usually by two kinds of possibilities: Transaction branch is timeout off, and the other is that this branch has not been launched at the ResourceManager end.
This article is mainly for 2 to do a description, for 1, we can in WebLogic Xaconnectionpool settings to enable XA Transaction Timeout, and set a reasonable value, recommended this value than global Transaction Timeout big. So WebLogic notifies RM when Xastart () is invoked, rather than using RM's own default timeout (for Oracle, default is 60 seconds, but typically at 120 seconds, TX Branch will be timeout by Oracle).
For 2, it is generally related to configuration, such as two XA datasource pointing to the same xaconnectionpool, or multiple xaconnectionpool pointing to the same database, For example, we point to the same connection with multiple DataSource:
1: If we have the following configuration environment:
Xadatasource_11---->XAPOOL_A---->databse_a
xadatasource_21---->xapool_b---->databse_b
In such a configuration environment, we do XA-related operations is not a problem.
1 public void xaTest()
2 {
3 try{
4 UserTransaction tx = getUserTransaction();
5 tx.setTransactionTimeout(1000);
6 tx.begin();
7 Connection conn1 = getConnection("t3://localhost:7011",XADatasource_11);
8 Connection conn2 = getConnection("t3://localhost:7021",XADatasource_21);
9 this.executeInsertInPSMT(conn1,null);
10 this.executeAnoInsertInPSMT(conn2,null);
11 conn1.close();
12 conn2.close();
13 tx.commit();
14 }catch(Exception e){}
15 }
2: If based on business needs, we need to configure an additional two XA Datasource, pointing to Xapool_a, Xapool_b, respectively, as follows:
Xadatasource_12----〉xapool_a
xadatasource_22----〉xapool_b
When deploying DataSource, WebLogic will judge whether this datasource is XA type, and if it is an Xa type datasource, we need to register this datasource instance to process- Wide's resourcedescriptorlist, as follows:
Registerresource (poolname, (XAResource) driverinstance,registrationproperties);
Before the register, we first call Unregisterresource (poolname) to resourcedescriptorlist the poolname corresponding resource from the unregister. After this Xadatasource_12, xadatasource_22 deployment, we can see the object changes in the Process-wide resourcedescriptorlist:
Before deployment: Xadatasource_11, xadatasource_21
After deployment: Xadatasource_12, xadatasource_22
Note: If XADatasource11, xadatasource_21, 22 do not have multiple data sources pointing to the same connection pool, after deployment, four DataSource should all appear in Resourcedescriptorlist.