3ur*_*och 2 java tomcat hibernate
在应用程序重新部署时在struts2 webapp中使用Hibernate,在重新部署后尝试访问页面时会出现此错误.
java.lang.IllegalStateException: Timer already cancelled.
Run Code Online (Sandbox Code Playgroud)
在重新部署tomcat之后,以下输出指示问题的原因是当webapp的第一个实例关闭时,Hibernate没有正常关闭.
Oct 15, 2010 8:58:34 PM org.apache.catalina.loader.WebappClassLoader clearReferencesStopTimerThread
SEVERE: A web application appears to have started a TimerThread named [Timer-0] via the java.util.Timer API but has failed to stop it. To prevent a memory leak, the timer (and hence the associated thread) has been forcibly cancelled.
Run Code Online (Sandbox Code Playgroud)
我已经在contextDestroyed方法中添加了一个ContextListener,但是这没有任何效果.
@Override
public void contextDestroyed(ServletContextEvent arg0) {
HibernateUtil.getSessionFactory().close();
}
Run Code Online (Sandbox Code Playgroud)
我还能做些什么来防止这个错误吗?
此警告是Tomcat 6.0.26附带的内存泄漏保护的一部分.在此特定问题中,您似乎使用commons-pool作为连接池.它没有正确终止计时器线程.这已被报告为错误:问题POOL-161.它尚未修复.
它确实没有伤害.Tomcat正在做正确的工作,只是接受这些警告.如果他们真的困扰你,你也可以考虑用另一个替换连接池.我推荐tomcat-jdbc.
| 归档时间: |
|
| 查看次数: |
4009 次 |
| 最近记录: |