在weblogic执行XA操作的时候,我们会碰到如下的错误,后来发现是JDBC配置的问题。
主要报错:
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
查了一下,XAER_NOTA说明transaction branch在ResourceManager端(DB, MQ等)不存在。不存在通常由两种可能:
1.transaction branch被timeout掉了,
2.就是这个branch压根就没有在ResourceManager端发起过。
对于1,可以在Weblogic的XAConnectionPool设定中Enable XA Transaction Timeout, 并对此设定一个合理的值,建议这个值比global transaction timeout大。这样weblogic在调用xaStart()的时候,会通知RM,该branch的timeout时间,而不是使用RM自己默认的timeout(对于Oracle, 默认为60秒,但一般会在120秒的时候,tx branch才会被Oracle timeout掉)。
对于2, 一般会跟配置有关系,比如两个XA datasource指向同一个XAConnectionPool, 或多个XAConnectionPool指向同一
个Database,
本例中原来的配置是只一个JDBC POOL:
本案例中详细的报错:
2009-12-30 13:50:27,219 DEBUG [IAAcctConnector] errorFlag : false
2009-12-30 13:50:27,234 ERROR [logger] Error Process = AcctCrmIbsDown
Error Node = NO_ENTRY
InstanceId = NO_ENTRY
BUsinessId = 376042
City = taizhou
Module Type = CrmIbs_Acct_EAI
Error Code = 6291476
Error Type = 16273440
Error Msg = SqlMapIAManageAcctOssCIDAO postAcct JDBC Exception; nested exception is
org.springframework.jdbc.CannotGetJdbcConnection
Exception: Could not get JDBC connection; nested exception is java.sql.SQLException: Unexpected exception
while enlisting XAConnecti
on 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
oracle.jdbc.xa.OracleXAException
at oracle.jdbc.xa.OracleXAResource.checkError(OracleXAResource.java:938)
at oracle.jdbc.xa.client.OracleXAResource.start(OracleXAResource.java:244)
at weblogic.jdbc.wrapper.VendorXAResource.start(VendorXAResource.java:50)
at weblogic.jdbc.jta.DataSource.start(DataSource.java:629)
at weblogic.transaction.internal.XAServerResourceInfo.start(XAServerResourceInfo.java:1140)
at weblogic.transaction.internal.XAServerResourceInfo.xaStart(XAServerResourceInfo.java:1072)
at weblogic.transaction.internal.XAServerResourceInfo.enlist(XAServerResourceInfo.java:240)
at weblogic.transaction.internal.ServerTransactionImpl.enlistResource
(ServerTransactionImpl.java:463)
at weblogic.jdbc.jta.DataSource.enlist(DataSource.java:1392)
at weblogic.jdbc.jta.DataSource.refreshXAConnAndEnlist(DataSource.java:1334)
at weblogic.jdbc.jta.DataSource.getConnection(DataSource.java:396)
at weblogic.jdbc.jta.DataSource.connect(DataSource.java:354)
at weblogic.jdbc.common.internal.RmiDataSource.getConnection(RmiDataSource.java:305)
at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:146)
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:100)
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:76)
at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:178)
at org.springframework.orm.ibatis.SqlMapClientTemplate.insert(SqlMapClientTemplate.java:309)
at com.ctzj.eai.cn.oss.CrmIbs.account.dao.ibatis.SqlMapIAManageAcctOssCIDAO.postAcct
(SqlMapIAManageAcctOssCIDAO.java:116)
at com.ctzj.eai.cn.oss.CrmIbs.account.task.IAAcctDBInsertAcctTask.execute
(IAAcctDBInsertAcctTask.java:71)
at com.ctzj.eai.cn.oss.CrmIbs.account.connector.IAAcctConnectorOut.handoverTask
(IAAcctConnectorOut.java:139)
at com.ctzj.eai.cn.oss.CrmIbs.account.connector.IAAcctConnectorOut.process
(IAAcctConnectorOut.java:191)
at com.ctzj.eai.cn.oss.CrmIbs.account.connector.IAAcctConnector.doAcctOutProcess
(IAAcctConnector.java:187)
at com.ctzj.eai.cn.oss.CrmIbs.account.connector.IAAcctConnector_xjttxc_ELOImpl.doAcctOutProcess
(IAAcctConnector_xjttxc_ELOIm
pl.java:207)
at com.ctzj.eai.cn.oss.IAC3OssAdapter.onMessage(IAC3OssAdapter.java:86)
at weblogic.ejb20.internal.MDListener.execute(MDListener.java:370)
at weblogic.ejb20.internal.MDListener.onMessage(MDListener.java:262)
at weblogic.jms.client.JMSSession.onMessage(JMSSession.java:2678)
at weblogic.jms.client.JMSSession.execute(JMSSession.java:2598)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)
at weblogic.jdbc.jta.DataSource.enlist(DataSource.java:1397)
at weblogic.jdbc.jta.DataSource.refreshXAConnAndEnlist(DataSource.java:1334)
at weblogic.jdbc.jta.DataSource.getConnection(DataSource.java:396)
at weblogic.jdbc.jta.DataSource.connect(DataSource.java:354)
at weblogic.jdbc.common.internal.RmiDataSource.getConnection(RmiDataSource.java:305)
at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:146)
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:100)
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:76)
at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:178)
at org.springframework.orm.ibatis.SqlMapClientTemplate.insert(SqlMapClientTemplate.java:309)
at com.ctzj.eai.cn.oss.CrmIbs.account.dao.ibatis.SqlMapIAManageAcctOssCIDAO.postAcct
(SqlMapIAManageAcctOssCIDAO.java:116)
at com.ctzj.eai.cn.oss.CrmIbs.account.task.IAAcctDBInsertAcctTask.execute
(IAAcctDBInsertAcctTask.java:71)
at com.ctzj.eai.cn.oss.CrmIbs.account.connector.IAAcctConnectorOut.handoverTask
(IAAcctConnectorOut.java:139)
at com.ctzj.eai.cn.oss.CrmIbs.account.connector.IAAcctConnectorOut.process
(IAAcctConnectorOut.java:191)
at com.ctzj.eai.cn.oss.CrmIbs.account.connector.IAAcctConnector.doAcctOutProcess
(IAAcctConnector.java:187)
at com.ctzj.eai.cn.oss.CrmIbs.account.connector.IAAcctConnector_xjttxc_ELOImpl.doAcctOutProcess
(IAAcctConnector_xjttxc_ELOIm
pl.java:207)
at com.ctzj.eai.cn.oss.IAC3OssAdapter.onMessage(IAC3OssAdapter.java:86)
at weblogic.ejb20.internal.MDListener.execute(MDListener.java:370)
at weblogic.ejb20.internal.MDListener.onMessage(MDListener.java:262)
at weblogic.jms.client.JMSSession.onMessage(JMSSession.java:2678)
at weblogic.jms.client.JMSSession.execute(JMSSession.java:2598)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)
SubSystem = 4
Cause = class org.springframework.jdbc.CannotGetJdbcConnectionException
StackTrace = at com.ctzj.eai.cn.oss.CrmIbs.account.dao.ibatis.SqlMapIAManageAcctOssCIDAO.postAcct
(SqlMapIAManageAcctOssCIDAO.java:12
0)
at com.ctzj.eai.cn.oss.CrmIbs.account.task.IAAcctDBInsertAcctTask.execute(IAAcctDBInsertAcctTask.java:71)
at com.ctzj.eai.cn.oss.CrmIbs.account.connector.IAAcctConnectorOut.handoverTask
(IAAcctConnectorOut.java:139)
at com.ctzj.eai.cn.oss.CrmIbs.account.connector.IAAcctConnectorOut.process(IAAcctConnectorOut.java:191)
at com.ctzj.eai.cn.oss.CrmIbs.account.connector.IAAcctConnector.doAcctOutProcess(IAAcctConnector.java:187)
at com.ctzj.eai.cn.oss.CrmIbs.account.connector.IAAcctConnector_xjttxc_ELOImpl.doAcctOutProcess
(IAAcctConnector_xjttxc_ELOImpl.java:
207)
at com.ctzj.eai.cn.oss.IAC3OssAdapter.onMessage(IAC3OssAdapter.java:86)
at weblogic.ejb20.internal.MDListener.execute(MDListener.java:370)
at weblogic.ejb20.internal.MDListener.onMessage(MDListener.java:262)
at weblogic.jms.client.JMSSession.onMessage(JMSSession.java:2678)
at weblogic.jms.client.JMSSession.execute(JMSSession.java:2598)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)
解决方法,将97_Pool clone一个为Sync97_Pool是重新配置如下,问题解决: