https://bz.apache.org/bugzilla/show_bug.cgi?id=58918
Bug ID: 58918 Summary: JNDI datasources shouldn't get the WebappClassLoader as their context ClassLoader when initializing Product: Tomcat 8 Version: 8.0.30 Hardware: PC OS: Linux Status: NEW Severity: normal Priority: P2 Component: Catalina Assignee: dev@tomcat.apache.org Reporter: yushijin...@gmail.com I use a JNDI datasource and put the mysql Connector/J driver in the $CATALINA_HOME/lib. When I undeploy a web application, I got a warning: 24-Jan-2016 20:26:52.254 WARNING [http-nio-8080-exec-5] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread: java.lang.Object.wait(Native Method) java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143) com.mysql.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:43) The reason is that Tomcat didn't set the thread context ClassLoader before initializing JNDI datasources, so the mysql driver gets a WebappClassLoader as its context ClassLoader. And then the [Abandoned connection cleanup thread] (created by mysql Connector/J) keeps a reference of the WebappClassLoader. This causes a memory leak. The suggest is to set the thread context ClassLoader to the container ClassLoader before initializing JNDI datasources. So they will get the container's ClassLoader as the context ClassLoader. Because JNDI datasources are global, they shouldn't be initialized with a ClassLoader of a webapp. I found a mailing list archive which tells the same bug: <https://mail-archives.apache.org/mod_mbox/tomcat-users/201305.mbox/%3c51a8c44d.8040...@christopherschultz.net%3E>. Sorry for my English;) -- You are receiving this mail because: You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org