Hi,
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.
Just 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?