开发者

java.lang.IllegalStateException: Timer already cancelled when webapp redeploys on tomcat

Using Hibernate in a struts2 webapp when the application redeploys I get this error when trying to access pages after redeploy.

java.lang.IllegalStateException: Timer already cancelled.

J开发者_高级运维ust after redeploy tomcat logs the following output which indicates the cause of the problem is that Hibernate is not shutting down properly when the first instance of the webapp is shutdown.

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. 

I have added a ContextListener which with the following in the contextDestroyed method but this has had no effect.

@Override
public void contextDestroyed(ServletContextEvent arg0) {

    HibernateUtil.getSessionFactory().close();

}

Is there anything else I can do to prevent this error?


This warning is part of memory leak protection which got shipped with Tomcat 6.0.26. In this particular issue, you seem to be using commons-pool as connection pool. It is not properly terminating the timer thread. This has already been reported as a bug: issue POOL-161. It's not fixed yet.

It does actually not harm. Tomcat is doing its job right, just live with those warnings. If they are really bothering you, you can also consider to replace the connection pool by another one. I'd recommend tomcat-jdbc.

See also:

  • Similar issue with commons DBCP
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜