Tomcat 6.0.26 or Higher Shutdown Reports 'A web application created a ThreadLocal .... ThreadLocal has been forcibly removed'

Symptoms

When starting up Tomcat (6.0.26 or higher), the log file reports that Catalina started with no issues:

INFO: Initializing Coyote HTTP/1.1 on http-8080Jun 8, 2010 3:10:23 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 379 ms
Jun 8, 2010 3:10:23 PM org.apache.catalina.core.StandardService startINFO: Starting service Catalina
Jun 8, 2010 3:10:23 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.26Jun 8, 2010 3:10:23 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor confluence.xml
......
INFO: Deploying web application directory ROOTJun 8, 2010 3:10:31 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Jun 8, 2010 3:10:31 PM org.apache.jk.common.ChannelSocket initINFO: JK: ajp13 listening on /0.0.0.0:8009
Jun 8, 2010 3:10:31 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/19  config=nullJun 8, 2010 3:10:31 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 8269 ms

When shutting down Tomcat, Catalina reports multiple threads have failed to stop:

Jun 8, 2010 3:50:57 PM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
SEVERE: A web application registered the JBDC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
Jun 8, 2010 3:50:57 PM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbcSEVERE: A web application registered the JBDC driver [org.postgresql.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.Jun 8, 2010 3:50:57 PM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
SEVERE: A web application registered the JBDC driver [org.hsqldb.jdbcDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
Jun 8, 2010 3:50:57 PM org.apache.catalina.loader.WebappClassLoader clearReferencesStopTimerThreadSEVERE: 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. Jun 8, 2010 3:50:57 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: A web application appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0] but has failed to stop it. This is very likely to create a memory leak.
Jun 8, 2010 3:50:57 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
...
SEVERE: A web application created a ThreadLocal with key of type [org.apache.log4j.helpers.ThreadLocalMap] (value [org.apache.log4j.helpers.ThreadLocalMap@4e4f2c1c]) and a value of type [java.util.Hashtable] (value [{referer=http://localhost:8080/confluence/setup/setuplicense.action, url=/confluence/setup/setupembeddeddb-default.action, userName=anonymous, action=setupembeddeddb-default}]) but failed to remove it when the web application was stopped. To prevent a memory leak, the ThreadLocal has been forcibly removed

Causes

There is a memory leak detection feature introduced in Tomcat 6.0.25 that attempts to log objects that have failed to be unregistered by webapps it hosts when they are stopped, and were forcibly unregistered by Tomcat. As Tomcat is forcibly removing these objects, it is not a serious concern that these log messages occur.

These errors will also appear during startup if your JDBC driver is not in the correct location on startup. If you are using a datasource, be sure to copy the JDBC drive to <confluence-install>/lib. If the issue persists, verify that you are able to authenticate against your database with the credentials supplied in your <confluence-home>/confluence.cfg.xml in the Hibernate connection settings.

Despite their apparent severity, these log messages are benign and can be safely ignored.

Resolution

There is no resolution at this time. There is an improvement request to reduce these harmless messages in the log during Confluence shutdown, which is being tracked at  CONF-22879 - Reduce errors logged when shutting down Confluence Open .

Workaround

As of this writing, the solution is to downgrade. Users can install Tomcat 6.0.20 as a workaround.

This workaround is not recommended as Tomcat 6.0.20 has known performance issues, and has several security vulnerabilities. We recommend customers upgrade to (or continue to run) Tomcat 6.0.32 or higher.

Was this helpful?

Thanks for your feedback!

Why was this unhelpful?

Have a question about this article?

See questions about this article

Powered by Confluence and Scroll Viewport