关于jboss运行时报错Transaction is not active: tx=TransactionImple
Caused by: org.hibernate.exception.GenericJDBCException: Cannot open connection
Caused by: org.jboss.util.NestedSQLException: Transaction is not active: tx=TransactionImple < ac, BasicAction: 7f000001:e069:4bdfc87a:312e status: ActionStatus.ABORT_ONLY >; - nested throwable: (javax.resource.ResourceException: Transaction is not active: tx=TransactionImple < ac, BasicAction: 7f000001:e069:4bdfc87a:312e status: ActionStatus.ABORT_ONLY >)
at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:95)
at org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider.getConnection(InjectedDataSourceConnectionProvider.java:47)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:423)
... 98 more
Caused by: javax.resource.ResourceException: Transaction is not active: tx=TransactionImple < ac, BasicAction: 7f000001:e069:4bdfc87a:312e status: ActionStatus.ABORT_ONLY >
at org.jboss.resource.connectionmanager.TxConnectionManager.getManagedConnection(TxConnectionManager.java:319)
at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:402)
at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:849)
at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:89)
... 100 more
2010-05-04 15:57:55,917 ERROR [STDERR] (http-0.0.0.0-8080-7) javax.ejb.EJBTransactionRolledbackException: org.hibernate.exception.GenericJDBCException: Cannot open connection
2010-05-04 15:57:55,918 ERROR [STDERR] (http-0.0.0.0-8080-7) at org.jboss.ejb3.tx.Ejb3TxPolicy.handleInCallerTx(Ejb3TxPolicy.java:87)
这个问题花了我一天的时间去解决。
首先,在网上找到方法,说是jboss设置事务的处理时间太短了。
解决方法:在JBOSS_HOME/server/default/conf/下,找到jboss-service.xml, 由默认的300秒 改多一点 如600秒
<!-- JBoss Transactions JTA -->
<mbean code="com.arjuna.ats.jbossatx.jta.TransactionManagerService"
name="jboss:service=TransactionManager">
<attribute name="TransactionTimeout">6000</attribute>
<attribute name="ObjectStoreDir">${jboss.server.data.dir}/tx-object-store</attribute>
</mbean>
修改这里后,jboss在执行事务的时候,不会那么快报错说事务超时了,但是过了大概半个小时后,还是报错事务超时(上面的异常)。这里有怀疑过,oracle执行的事务有没有超时这个概念?
然后,想到了触发上线是以服务器的时间为准的,我就把包部署到本地,修改我本机的时间,一部分一部分地上线了,投机取巧,呵呵。最后成功解决这个问题。
这里,触发上线很慢,二十多分钟才update了两百多条记录,性能上很大问题,不过,这里涉及到xml文件,也是正常。