WAS的Transaction问题,请指教

04-02-11 abc14700
我在项目的EJB使用中碰到一个问题,设计了两个EJB的应用,都是使用CMT,并且Transaction Attribute设为Required,这两个bean其实非常简单,一个是stateless session bean,一个是cmp entity bean,前者有3个方法,其中一个通过JDBC访问数据库的方法(test1),另有一个利用后者(CMP)访问数据库的方法(test2),最后一个是调用这三个方法的方法(test)。对test1,test2分别调用都是完全没有问题的。而且如果从test中注释掉对其中一个方法的调用,则不会出现问题。唯一会出现问题的是两个方法同时调用(在一个方法里面)的时候。

即在stateless session bean中为

test(){

test2();

test1();

}

我使用了在test1中两种数据源(XA和非XA的数据源)进行了测试,当执行到conn.createStatement();时出现异常

我的测试环境:

Win2000 Server+WebSphere 5 + oracle8.1.7

当使用XA的数据源时的异常如下:

[04-2-10 14:48:06:163 CST] be96d3d XATransaction E J2CA0027E: 当调用 start(在数据库 jdbc/oraclezzpsXAdatasource 的 XA 资源适配器上,事务标识 {XID: formatId(57415344), gtrid_length(26), bqual_length(25), data(00000001 01148B69 3394A48B 5A353C72 43312964 B9231F46 B6A8018B 693394A4 8B5A353C 72433129 64B9231F 46B6A820 2D5912)} 中)时,发生异常:java.lang.NullPointerException

at com.ibm.ws.rsadapter.spi.WSRdbXaResourceImpl.start(WSRdbXaResourceImpl.java:807)

at com.ibm.ejs.j2c.XATransactionWrapper.start(XATransactionWrapper.java:1405)

at com.ibm.ejs.jts.jta.WSResourceImplBase.start(WSResourceImplBase.java:164)

at com.ibm.ejs.jts.jta.TransactionImpl.enlistResource(TransactionImpl.java:730)

at com.ibm.ejs.jts.jta.JTSXA.enlist(JTSXA.java:998)

at com.ibm.ejs.j2c.XATransactionWrapper.enlist(XATransactionWrapper.java:740)

at com.ibm.ejs.j2c.ConnectionEventListener.interactionPending(ConnectionEventListener.java:743)

at com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl.processInteractionPendingEvent(WSRdbManagedConnectionImpl.java:1299)

at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.beginTransactionIfNecessary(WSJdbcConnection.java:328)

at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.createStatement(WSJdbcConnection.java:697)

at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.createStatement(WSJdbcConnection.java:673)

at com.enjoyInfo.zzps.infraStructure.dataAccessObject.DAO.getResultSet(DAO.java:58)

at com.enjoyInfo.zzps.infraStructure.dataAccessObject.DAO.getDtoTabular(DAO.java:99)

at com.enjoyInfo.zzps.infraStructure.dataAccessObject.OraclePublicDAO.getSimpleTreeNodeTabular(OraclePublicDAO.java:148)

at com.enjoyInfo.zzps.infraStructure.dataAccessObject.OraclePublicDAO.getTreeNodeTabularOfTreeViewFrom(OraclePublicDAO.java:171)

at com.enjoyInfo.zzps.infraStructure.treeView.TreeViewImpl.getChildNodes(TreeViewImpl.java:120)

at com.enjoyInfo.zzps.infraStructure.treeView.treeViewSessionEJB.EJSLocalStatelessTreeViewSession_8df38fd6.getChildNodes(EJSLocalStatelessTreeViewSession_8df38fd6.java:167)

at java.lang.reflect.Method.invoke(Native Method)

at com.ibm.etools.utc.model.ReflectionMethodModel.invoke(ReflectionMethodModel.java:68)

at com.ibm.etools.utc.servlet.InvokeServlet.invoke(InvokeServlet.java:110)

at com.ibm.etools.utc.servlet.InvokeServlet.doPost(InvokeServlet.java:352)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)

at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)

at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)

at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)

at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)

at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)

at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)

at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:948)

at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:530)

at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:176)

at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:79)

at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:201)

at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)

at com.ibm.ws.webcontainer.cache.invocation.CacheableInvocationContext.invoke(CacheableInvocationContext.java:114)

at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:186)

at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)

at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)

at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:610)

at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:431)

at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:593)

[04-2-10 14:48:08:335 CST] be96d3d XATransaction E J2CA0030E: 方法 enlist 捕捉到 javax.transaction.SystemException: Failed to start the transaction association.

at com.ibm.ejs.jts.jta.TransactionImpl.enlistResource(TransactionImpl.java:782)

at com.ibm.ejs.jts.jta.JTSXA.enlist(JTSXA.java:998)

at com.ibm.ejs.j2c.XATransactionWrapper.enlist(XATransactionWrapper.java:740)

at com.ibm.ejs.j2c.ConnectionEventListener.interactionPending(ConnectionEventListener.java:743)

at com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl.processInteractionPendingEvent(WSRdbManagedConnectionImpl.java:1299)

at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.beginTransactionIfNecessary(WSJdbcConnection.java:328)

at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.createStatement(WSJdbcConnection.java:697)

at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.createStatement(WSJdbcConnection.java:673)

at com.enjoyInfo.zzps.infraStructure.dataAccessObject.DAO.getResultSet(DAO.java:58)

at com.enjoyInfo.zzps.infraStructure.dataAccessObject.DAO.getDtoTabular(DAO.java:99)

at com.enjoyInfo.zzps.infraStructure.dataAccessObject.OraclePublicDAO.getSimpleTreeNodeTabular(OraclePublicDAO.java:148)

at com.enjoyInfo.zzps.infraStructure.dataAccessObject.OraclePublicDAO.getTreeNodeTabularOfTreeViewFrom(OraclePublicDAO.java:171)

at com.enjoyInfo.zzps.infraStructure.treeView.TreeViewImpl.getChildNodes(TreeViewImpl.java:120)

at com.enjoyInfo.zzps.infraStructure.treeView.treeViewSessionEJB.EJSLocalStatelessTreeViewSession_8df38fd6.getChildNodes(EJSLocalStatelessTreeViewSession_8df38fd6.java:167)

at java.lang.reflect.Method.invoke(Native Method)

at com.ibm.etools.utc.model.ReflectionMethodModel.invoke(ReflectionMethodModel.java:68)

at com.ibm.etools.utc.servlet.InvokeServlet.invoke(InvokeServlet.java:110)

at com.ibm.etools.utc.servlet.InvokeServlet.doPost(InvokeServlet.java:352)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)

at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)

at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)

at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)

at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)

at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)

at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)

at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:948)

at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:530)

at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:176)

at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:79)

at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:201)

at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)

at com.ibm.ws.webcontainer.cache.invocation.CacheableInvocationContext.invoke(CacheableInvocationContext.java:114)

at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:186)

at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)

at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)

at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:610)

at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:431)

at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:593)

(当尝试使用事务管理器为当前事务从数据源 jdbc/oraclezzpsXAdatasource 将资源加入列表时),并抛出 ResourceException。

当使用非XA的数据源时的异常如下:

[04-2-10 15:43:05:412 CST] 3d007558 TransactionIm E WTRN0062E: 在全局事务中发生非法尝试使用多个仅有一阶段能力的资源。

[04-2-10 15:43:05:849 CST] 3d007558 LocalTransact E J2CA0030E: 方法 enlist 捕捉到 java.lang.IllegalStateException

at com.ibm.ejs.jts.jta.TransactionImpl.enlistResource(TransactionImpl.java:567)

at com.ibm.ejs.jts.jta.JTSXA.enlistResource(JTSXA.java:1061)

at com.ibm.ejs.jts.jta.JTSXA.enlistOnePhase(JTSXA.java:1038)

at com.ibm.ejs.j2c.LocalTransactionWrapper.enlist(LocalTransactionWrapper.java:507)

at com.ibm.ejs.j2c.ConnectionEventListener.interactionPending(ConnectionEventListener.java:743)

at com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl.processInteractionPendingEvent(WSRdbManagedConnectionImpl.java:1299)

at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.beginTransactionIfNecessary(WSJdbcConnection.java:328)

at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.createStatement(WSJdbcConnection.java:697)

at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.createStatement(WSJdbcConnection.java:673)

at com.enjoyInfo.zzps.infraStructure.dataAccessObject.DAO.getResultSet(DAO.java:58)

at com.enjoyInfo.zzps.infraStructure.dataAccessObject.DAO.getDtoTabular(DAO.java:101)

at com.enjoyInfo.zzps.infraStructure.dataAccessObject.OraclePublicDAO.getSimpleTreeNodeTabular(OraclePublicDAO.java:148)

at com.enjoyInfo.zzps.infraStructure.dataAccessObject.OraclePublicDAO.getTreeNodeTabularOfTreeViewFrom(OraclePublicDAO.java:171)

at com.enjoyInfo.zzps.infraStructure.treeView.TreeViewImpl.getChildNodes(TreeViewImpl.java:120)

at com.enjoyInfo.zzps.infraStructure.treeView.treeViewSessionEJB.EJSLocalStatelessTreeViewSession_8df38fd6.getChildNodes(EJSLocalStatelessTreeViewSession_8df38fd6.java:167)

at java.lang.reflect.Method.invoke(Native Method)

at com.ibm.etools.utc.model.ReflectionMethodModel.invoke(ReflectionMethodModel.java:68)

at com.ibm.etools.utc.servlet.InvokeServlet.invoke(InvokeServlet.java:110)

at com.ibm.etools.utc.servlet.InvokeServlet.doPost(InvokeServlet.java:352)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)

at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)

at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)

at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)

at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)

at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)

at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)

at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:948)

at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:530)

at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:176)

at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:79)

at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:201)

at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)

at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:182)

at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)

at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)

at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:610)

at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:431)

at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:593)

(当尝试使用事务管理器为当前事务从数据源 jdbc/oraclezzpsdaodatasource 将资源加入列表时),并抛出 Exception。

abc14700
2004-02-11 20:07
如果你们碰到过类似的问题,或者知道解决办法,大家交流一下,建议也可以。如果有Websphere的专家推荐给我就更好了。多谢大家先!

我研究这个问题化了n天,进度严重落后,在线等

abc14700
2004-02-11 20:09
如果你们碰到过类似的问题,或者知道解决办法,大家交流一下,建议也可以。如果有Websphere的专家推荐给我就更好了。多谢大家先!

我研究这个问题化了n天,进度严重落后,在线等

windjp
2004-02-12 17:11
是分布式事务的应用嘛?如果是的话一定要配xa数据源,第二个异常是说你的资源不支持两阶段提交。

你说的方式我用过,如果是连同一个数据库的话是肯定可以的,不用使用xa数据源。如果是分布式事务的话,问题就复杂一些了,要多做些测试定位问题。

猜你喜欢