zoukankan      html  css  js  c++  java
  • The web application [] appears to have started a thread named [Abandoned connection cleanup thread] com.mysql.jdbc.AbandonedConnectionCleanupThread

    01-Jul-2016 14:25:30.937 WARNING [localhost-startStop-1] 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(ReferenceQueue.java:143)
     com.mysql.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:43)

    解决方式:

    package reyo.sdk.utils.mysql;

    import java.sql.Driver;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    import java.util.Enumeration;

    import javax.servlet.ServletContextEvent;
    import javax.servlet.ServletContextListener;
    import javax.servlet.annotation.WebListener;

    import com.mysql.jdbc.AbandonedConnectionCleanupThread;

    @WebListener
    public class ContextFinalizer implements ServletContextListener {

        public void contextInitialized(ServletContextEvent sce) {
        }

        public void contextDestroyed(ServletContextEvent sce) {
            Enumeration<Driver> drivers = DriverManager.getDrivers();
            Driver d = null;
            while (drivers.hasMoreElements()) {
                try {
                    d = drivers.nextElement();
                    DriverManager.deregisterDriver(d);
                    System.out.println(String.format("ContextFinalizer:Driver %s deregistered", d));
                } catch (SQLException ex) {
                    System.out.println(String.format("ContextFinalizer:Error deregistering driver %s", d) + ":" + ex);
                }
            }
            try {
                AbandonedConnectionCleanupThread.shutdown();
            } catch (InterruptedException e) {
                System.out.println("ContextFinalizer:SEVERE problem cleaning up: " + e.getMessage());
                e.printStackTrace();
            }
        }
    }

  • 相关阅读:
    scikit_learn 官方文档翻译(集成学习)
    机器学习之SVM与逻辑回归的联系和区别
    有序数组寻找中位数以及寻找K大元素
    有向图算法之拓扑排序
    机器学习之离散型特征处理--独热码(one_hot_encoding)
    计算广告学(2)--广告有效性模型
    机器学习实战--k-均值聚类
    SonarQube 扫描代码,SonarQube 进行代码质量检查
    Docker 搭建 Nexus3
    informix 安装 linux 客户端
  • 原文地址:https://www.cnblogs.com/interdrp/p/5633020.html
Copyright © 2011-2022 走看看