viviallddn
anthonliu · 2004-11-25
weblogic 分布式事务处理经常遇到的XA异常处理方法
2004-11-25
Tag:
Web_Server_&_EJB_Server
版权声明
:转载时请以超链接形式标明文章原始出处和作者信息及
本声明
http://anthonliu.blogbus.com/logs/514546.html
weblogic 分布式事务处理经常遇到的XA异常处理方法前提:用Weblogic XA类型的驱动程序,选中'SupportLocalTransaction'.
这些错误都默名奇妙,费了好大尽才找到答案.
错误1:
java.sql.SQLException: XA error: XAER_PROTO : Routine was invoked in an inproper context start() failed on resource 'InitialPool': XAER_PROTO : Routine was invoked in an inproper context
javax.transaction.xa.XAException
at oracle.jdbc.xa.OracleXAResource.disallowLocalTxnMode(OracleXAResource.java:1047)
at oracle.jdbc.xa.client.OracleXAResource.start(OracleXAResource.java:153)
at weblogic.jdbc.wrapper.VendorXAResource.start(VendorXAResource.java:50)
at weblogic.jdbc.jta.DataSource.start(DataSource.java:604)
at weblogic.transaction.internal.XAServerResourceInfo.sta
解决:
If the XA driver supports performing SQL operations with no global transaction, explicitly allow it by setting "SupportsLocalTransaction" JDBC connection pool property to true. In this case, also remember to complete the local transaction before using the connection again for global transaction, else a XAER_OUTSIDE XAException may result. To complete a local transaction, you can either set auto commit to true or call Connection.commit() or Connection.rollback().
也就是说,如果在同一个线程中,对于同一个连接池,先执行本地事务,接着取连接执行分布式事务要么明确用con.setAutoCommit(true),要么用con.setAutoCommit(false)/con.begin/con.rollback来完成本地事务。一般在前台页面开发时会遇到这样的问题:比如先通过InitialWebPublicPara来初始化页面,接着调用别人的EJB方法
最明显的是用下面的例子会出错:
java.sql.Connection con1 =
ConnectionManager.getConnection("BossInitDS");
//con1.setAutoCommit(true);
java.sql.Statement stmt = con1.createStatement();
stmt.executeQuery("select 1 from dual");
stmt.close();
con1.close();
//直接这样,或调用一个EJB方法(EJB方法中取连接)
javax.transaction.UserTransaction ut = weblogic.transaction.TxHelper.getUserTransaction();
ut.begin();
java.sql.Connection con =
ConnectionManager.getConnection("BossInitDS");
ut.commit();
con.close();
错误2:
错误a.ORA-01000: maximum open cursors exceeded
错误b.[java.sql.SQLException: XA error: XAER_RMERR : A resource manager error has occured in the transaction branch start() failed on resource 'weblogic.jdbc.jta.DataSource': XAER_RMERR : A resource manager error has occured in the transaction branch
oracle.jdbc.xa.OracleXAException
at oracle.jdbc.xa.OracleXAResource.checkError(OracleXAResource.java:1159)
at oracle.jdbc.xa.client.OracleXAResource.start(OracleXAResource.java:311)
at weblogic.jdbc.wrapper.VendorXAResource.start(VendorXAResource.java:50)
at weblogic.jdbc.jta.DataSource.start(DataSource.java:604)
at weblogic.transaction.internal.XAServerResourceInfo.start(XAServerResourceInfo.java:1069)
at weblogic.transaction.internal.XAServerResourceInfo.xaStart(XAServerResourceInfo.java:1001)
at weblogic.transaction.internal.XAServerResourceInfo.enlist(XAServerResourceInfo.java:203)
at weblogic.transaction.internal.ServerTransactionImpl.enlistResource(ServerTransactionImpl.java:419)
解决:
To prepare the database for XA, perform these steps:
1. Log on to sqlplus as system user, e.g.
sqlplus sys/CHANGE_ON_INSTALL@<DATABASE ALIAS NAME>
2. Execute the sql: grant select on DBA_PENDING_TRANSACTIONS to user where user is the user account used to create database connections in a connection pool. Execute this command for each user account used in XA connection pools in your WebLogic Server domain.
If the above steps are not performed on the database server, normal XA database queries and updates may work fine. However, when the Weblogic Server Transaction Manager performs recovery on a re-boot after a crash, recover for the Oracle resource will fail with XAER_RMERR. Crash recovery is a standard operation for an XA resource.
这完全是数据库对XA的支持引起的,数据库管理员要执行上面的两个步骤,这个错误没什么规律,时而好使。我先遇到了,可能大家以后都不会遇到了
相关文章:
CMD小技巧
2004-11-19
26个字母的爱情意义。。。
2004-11-15
颜色暴露你的秘密 从喜欢的颜色偷窥你的内心
2004-11-15
Weblogic 问题
2004-11-14
屏蔽tomcat的目录列表功能
2004-11-14
收藏到:
Del.icio.us
引用地址:
viviallddn
发表于
08:42
|
编辑
|
继续话题
|
转发
|
推荐
发表评论
原始快照:web.archive.org