[英]Java spring database application won't quit reference to org.enhydra.jdbc.pool.PoolKeeper is still active why?
Hello all I have a simple Spring application which will not end as there is still a reference left to org.enhydra.jdbc.pool.PoolKeeper. 大家好,我有一个简单的Spring应用程序,该应用程序将不会结束,因为仍然有对org.enhydra.jdbc.pool.PoolKeeper的引用。 I include all the references I feel are revelant below does it look ok and has anyone experienced this before?
我在下面列出了我认为很容易理解的所有参考资料,看起来还不错,以前有没有人经历过?
I ran jstack to see what non daemon threads where running and found the following. 我运行jstack来查看运行了哪些非守护程序线程,并发现了以下内容。
"Thread-1" prio=10 tid=0x00007f89b03d8000 nid=0x755 in Object.wait() [0x00007f89bc243000] java.lang.Thread.State: TIMED_WAITING (on object monitor) at java.lang.Object.wait(Native Method)
- waiting on <0x00007f89ec57de00> (a org.enhydra.jdbc.pool.PoolKeeper) at org.enhydra.jdbc.pool.PoolKeeper.run(PoolKeeper.java:55)
- locked <0x00007f89ec57de00> (a org.enhydra.jdbc.pool.PoolKeeper) at java.lang.Thread.run(Thread.java:619)
Now I am confused as to why this is happening I include relevant parts of my JPA configuration 现在,我对为什么发生这种情况感到困惑,我将JPA配置的相关部分包括在内
<bean id="innerDataSource" class="org.enhydra.jdbc.standard.StandardXADataSource"
destroy-method="shutdown">
<property name="transactionManager" ref="jotm" />
<property name="driverName" value="${jdbc.driverClassName}"/>
<property name="url" value ="${jdbc.url}"/>
<property name="user" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
</bean>
<bean id="dataSource" class="org.enhydra.jdbc.pool.StandardXAPoolDataSource"
destroy-method="shutdown">
<property name="dataSource" ref="innerDataSource"/>
<property name="user" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
<property name="maxSize" value="100" />
<!-- test your jdbc connection before using it -->
<property name="checkLevelObject" value="${jdbc.checkLevelObject}"/>
<property name="jdbcTestStmt" value="${jdbc.jdbcTestStmt}"/>
</bean>
Thanks Paul 谢谢保罗
Web applications typically configure a Spring application context using ContextLoaderListener
, which closes the application context when the Web application is stopped. Web应用程序通常使用
ContextLoaderListener
配置Spring应用程序上下文,该上下文在Web应用程序停止时关闭应用程序上下文。
Standalone Java applications have to call the close
method on the application context, which invokes the methods configured in the destroy-method
attribute while destroying the beans. 独立的Java应用程序必须在应用程序上下文中调用
close
方法,该destroy-method
将在销毁bean时调用destroy-method
属性中配置destroy-method
。 Alternatively, call the registerShutdownHook
method to register a shutdown hook that closes the application context on JVM shutdown. 或者,调用
registerShutdownHook
方法来注册一个关闭挂钩,该挂钩在JVM关闭时关闭应用程序上下文。
Your Spring file looks correct to me based on the enhydra javadoc (which is sparse on details). 根据enhydra javadoc(详细信息很少),您的Spring文件对我而言似乎正确。 I did see a
stopPool()
method in the API. 我确实在API中看到了
stopPool()
方法。 Perhaps try that in your destroy-method
? 也许尝试使用您的
destroy-method
?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.