用weblogic的数据源+ejb开发,经常遇到下面的情况:
调用ejb接口,操作数据库的时候,时间超过29秒就会报错,相信错误信息如下:
--- Cause: java.sql.SQLException: The transaction is no longer active - status: 'Marked rollback. [Reason=weblogic.transaction.internal.TimedOutException: Transaction timed out after 29 seconds
BEA1-007896384D22CA217E0D]'. No further JDBC access is allowed within this transaction.
at weblogic.ejb.container.internal.EJBRuntimeUtils.throwRemoteException(EJBRuntimeUtils.java:95)
at weblogic.ejb.container.internal.BaseEJBObject.handleSystemException(BaseEJBObject.java:724)
at weblogic.ejb.container.internal.BaseEJBObject.handleSystemException(BaseEJBObject.java:681)
at weblogic.ejb.container.internal.BaseEJBObject.postInvoke1(BaseEJBObject.java:447)
at weblogic.ejb.container.internal.StatelessEJBObject.postInvoke1(StatelessEJBObject.java:72)
at weblogic.ejb.container.internal.BaseEJBObject.postInvokeTxRetry(BaseEJBObject.java:374)
at com.comtop.dqmp.problemprocessing.quarterssetting.ejb.RuleTypeSetSes_owd7d8_EOImpl.insertRuleTypeSet(RuleTypeSetSes_owd7d8_EOImpl.java:219)
at com.comtop.dqmp.problemprocessing.quarterssetting.ejb.RuleTypeSetSes_owd7d8_EOImpl_CBV.insertRuleTypeSet(Unknown Source)
at com.comtop.dqmp.problemprocessing.quarterssetting.delegate.RuleTypeSetMan.insertRuleTypeSet(RuleTypeSetMan.java:113)
at com.comtop.dqmp.problemprocessing.quarterssetting.action.QuartersSettingListAction.doSetQuartersOperation(QuartersSettingListAction.java:155)
at com.comtop.dqmp.problemprocessing.quarterssetting.action.QuartersSettingListAction.execute(QuartersSettingListAction.java:60)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at com.comtop.struts.action.ComtopActionServlet.process(ComtopActionServlet.java:78)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:225)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:127)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at com.comtop.struts.action.ValidatorSessionFilterSys.doFilter(ValidatorSessionFilterSys.java:186)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at com.comtop.struts.logon.UserAreaCodeFilter.doFilter(UserAreaCodeFilter.java:61)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3212)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:1983)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:1890)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1344)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:181)
这个很明显就是weblogic的数据源连接出错了,默认是29秒操作没完成,操作的该连接事务自动回滚,修正方法:
进入weblogic的控制台,点击service--jta
Timeout Seconds:120(超时时间,根据自己的情况设置)
Abandon Timeout Seconds:设置到一些,weblogic默认是86400
ejb的时间设置方法:
打开weblogic-ejb-jar.xml文件
EJB默认的事务超时时间为30秒(一般29秒就报错)
<weblogic-ejb-jar>
<weblogic-enterprise-bean>
<ejb-name>test</ejb-name>
<jndi-name>test</jndi-name>
<transaction-descriptor>
<trans-timeout-seconds>120</trans-timeout-seconds>
</transaction-descriptor>
</weblogic-enterprise-bean>
</weblogic-ejb-jar>