我有一个在Websphere Application Server 6.0(WAS)内的Websphere Portal Server中运行的应用程序。在此应用程序中,由于需要花费很长时间才能完成一项特定功能,因此我将触发执行此操作的新线程。这个新线程从Hibernate打开一个新的Session,并开始使用它执行数据库事务。有时(无法看到模式),线程内的事务工作正常,并且该过程成功完成。但是其他时候我得到以下错误:

org.hibernate.exception.GenericJDBCException: could not load an entity: [OBJECT NAME#218294]
...
Caused by: com.ibm.websphere.ce.cm.ObjectClosedException: DSRA9110E: Connection is closed.
Method cleanup failed while trying to execute method cleanup on ManagedConnection WSRdbManagedConnectionImpl@642aa0d8 from resource jdbc/MyJDBCDataSource. Caught exception: com.ibm.ws.exception.WsException: DSRA0080E: An exception was received by the Data Store Adapter. See original exception message: Cannot call 'cleanup' on a ManagedConnection while it is still in a transaction..


我该如何阻止这种情况的发生?为什么WAS似乎要杀死我的连接,即使它们没有完成也是如此。有没有一种方法可以阻止WAS尝试关闭此特定连接?

谢谢

最佳答案

我在other answer中提到了两个可能的原因:1. hibernate.connection.release_mode可选参数或2. unmanaged threads出现问题。现在,我阅读了这个问题,我真的开始认为您的问题可能与您生成自己的线程有关。由于它们不是由容器管理的,因此这些胎面中使用的连接可能显示为“泄漏”(未正确关闭),如果WAS尝试在某个时间恢复它们,我也不会感到惊讶。

如果要开始长时间运行的作业,则应使用WorkManager。不要自己生成线程。

10-06 07:22