用于在Websphere中关闭后台线程的JDBC连接 [英] JDBC connection for a background thread being closed accessing in Websphere

查看:1232
本文介绍了用于在Websphere中关闭后台线程的JDBC连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

  org.hibernate.exception.GenericJDBCException:无法加载实体:[OBJECT NAME #218294] 
...
导致:com.ibm.websphere.ce.cm.ObjectClosedException:DSRA9110E:连接已关闭。
尝试从资源jdbc / MyJDBCDataSource对ManagedConnection WSRdbManagedConnectionImpl @ 642aa0d8执行方法清除时,方法清除失败。找到异常:com.ibm.ws.exception.WsException:DSRA0080E:Data Store适配器收到异常。查看原始异常消息:在ManagedConnection仍处于事务中时,无法调用'cleanup'。

我怎样才能阻止这种情况发生?为什么看起来WAS想要杀掉我的连接,即使它们没有完成。有没有办法阻止WAS试图关闭这个特定的连接?



谢谢

解决方案

我在:1. hibernate.connection.release_mode 可选参数或2. 非托管线程。现在我读到这个问题了,我真的开始认为你的问题可能与你产生自己的线程有关。由于它们不是由容器管理的,因此在这些踏面中使用的连接可能会显示为泄漏(未正确关闭),如果WAS尝试在某个点恢复它们,我不会感到惊讶。

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


I have an application running in Websphere Portal Server inside of Websphere Application Server 6.0 (WAS). In this application for one particular functionality that takes a long time to complete, I am firing a new thread that performs this action. This new thread opens a new Session from Hibernate and starts performing DB transactions with it. Sometimes (haven't been able to see a pattern), the transactions inside the thread work fine and the process completes successfully. Other times however I get the errors below:

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..

How can I stop this from happening? Why does it seem that WAS wants to kill my connections even though they're not done. Is there a way I can stop WAS from attempting to close this particular connection?

Thanks

解决方案

I mentioned two possible causes in my other answer: 1. the hibernate.connection.release_mode optional parameter or 2. a problem with unmanaged threads. Now that I read this question, I really start to think that your problem may be related to the fact that you're spawning your own threads. Since they aren't managed by the container, connections used in these treads may appear as "leaked" (not closed properly) and I wouldn't be surprised if WAS tries to recover them at some point.

If you want to start a long running job, you should use a WorkManager. Don't spawn threads yourself.

这篇关于用于在Websphere中关闭后台线程的JDBC连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆