I am using Tomcat 9.0.8 with MySQL database Ver 8.0.11 and mysql-connector-java Version 8.0.11
I have implemented a Listener and in the contextDestroy(), I am de-registering all the JDBC drivers as below:
Enumeration<Driver> l_drivers = DriverManager.getDrivers();
while (l_drivers.hasMoreElements()) {
Driver l_driver = l_drivers.nextElement();
try {
LOGGER.info("De-registering JDBC driver :: {}",l_driver.getClass().getName());
DriverManager.deregisterDriver(l_driver);
} catch (Exception e) {
LOGGER.error("Error deregistering Driver:: {}", l_driver);
LOGGER.error(e.getMessage(), e);
}
}
But still every time I re-deploy/re-load/shutdown I get the below memory leak warning message in Tomcat Logs:
13-May-2018 00:02:01.354 WARNING [main] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads
The web application [xxxxx] 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.cj.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:70)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
java.lang.Thread.run(Thread.java:748)
13-May-2018 00:02:01.387 INFO [main] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["http-nio-8082"]
13-May-2018 00:02:01.392 INFO [main] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["ajp-nio-8010"]
13-May-2018 00:02:01.397 INFO [main] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["http-nio-8082"]
13-May-2018 00:02:01.398 INFO [main] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["ajp-nio-8010"]
So I am not sure why I still get this warning? I have another web-app which runs with MySQL 5.7 and MySQL Connector 6.0.6 and there I am not facing this issue with exactly same code in the contextDestroy().
Am I missing something in the version 8?
OS: Ubuntu 18.04 LTS, Java 1.8
I have implemented a Listener and in the contextDestroy(), I am de-registering all the JDBC drivers as below:
Enumeration<Driver> l_drivers = DriverManager.getDrivers();
while (l_drivers.hasMoreElements()) {
Driver l_driver = l_drivers.nextElement();
try {
LOGGER.info("De-registering JDBC driver :: {}",l_driver.getClass().getName());
DriverManager.deregisterDriver(l_driver);
} catch (Exception e) {
LOGGER.error("Error deregistering Driver:: {}", l_driver);
LOGGER.error(e.getMessage(), e);
}
}
But still every time I re-deploy/re-load/shutdown I get the below memory leak warning message in Tomcat Logs:
13-May-2018 00:02:01.354 WARNING [main] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads
The web application [xxxxx] 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.cj.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:70)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
java.lang.Thread.run(Thread.java:748)
13-May-2018 00:02:01.387 INFO [main] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["http-nio-8082"]
13-May-2018 00:02:01.392 INFO [main] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["ajp-nio-8010"]
13-May-2018 00:02:01.397 INFO [main] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["http-nio-8082"]
13-May-2018 00:02:01.398 INFO [main] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["ajp-nio-8010"]
So I am not sure why I still get this warning? I have another web-app which runs with MySQL 5.7 and MySQL Connector 6.0.6 and there I am not facing this issue with exactly same code in the contextDestroy().
Am I missing something in the version 8?
OS: Ubuntu 18.04 LTS, Java 1.8