发表于 2017-02-27 15:39


27-Feb-2017 15:23:52.919 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesJdbc The web application [ROOT] registered the JDBC 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.
27-Feb-2017 15:23:52.920 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [ROOT] 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(

查了下之后发现需要手动解除注册以及关闭mysql的AbandonedConnectionCleanupThread线程"Destroying Context...");

try {"Calling MySQL AbandonedConnectionCleanupThread shutdown");

} catch (InterruptedException e) {
    log.error("Error calling MySQL AbandonedConnectionCleanupThread shutdown {}", e);

ClassLoader cl = Thread.currentThread().getContextClassLoader();

Enumeration<Driver> drivers = DriverManager.getDrivers();
while (drivers.hasMoreElements()) {
    Driver driver = drivers.nextElement();

    if (driver.getClass().getClassLoader() == cl) {

        try {
  "Deregistering JDBC driver {}", driver);

        } catch (SQLException ex) {
            log.error("Error deregistering JDBC driver {}", driver, ex);

    } else {
        log.trace("Not deregistering JDBC driver {} as it does not belong to this webapp's ClassLoader", driver);