我有两个 bean:FirstBean和SecondBean。
FirstBean有方法method1和 REQUIRED 事务属性,SecondBean有方法method2和 NOT_SUPPORTED 事务属性。方法 1 调用方法 2。
@Stateless
class FirstBean implement IFirstBean
{
ISecondBean secondBean;
@TransactionAttribute(TransactionAttributeType.REQUIRED)
void method1()
{
//...
secondBean.method2()
//...
}
}
@Stateless
class SecondBean implement ISecondBean
{
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
void method2()
{
//....
}
}
它运作良好。
但是当method2工作很长时间(超过4-5分钟)我在JBoss 4服务器上遇到异常
Caused by: java.lang.IllegalStateException: [com.arjuna.ats.internal.jta.transaction.arjunacore.inactive] [com.arjuna.ats.internal.jta.transaction.arjunacore.inactive] The transaction is not active!
at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1379)
at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:135)
接下来是 WebLogic 10.3
Caused By: org.hibernate.SessionException: Session is closed!
at org.hibernate.impl.AbstractSessionImpl.errorIfClosed(AbstractSessionImpl.java:49)
at org.hibernate.impl.SessionImpl.clear(SessionImpl.java:253)
method1 完成后抛出异常