복붙노트

[SPRING] 웹 응용 프로그램 []이 [Abandoned connection cleanup thread]라는 스레드를 시작한 것 같습니다. com.mysql.jdbc.AbandonedConnectionCleanupThread

SPRING

웹 응용 프로그램 []이 [Abandoned connection cleanup thread]라는 스레드를 시작한 것 같습니다. com.mysql.jdbc.AbandonedConnectionCleanupThread

내 웹 개발 중간에 Eclipse IDE에서 웹 응용 프로그램을 닫습니다. 약 1 분만에 Eclipse 콘솔에서 WARNING을 보았습니다.

WARNING: The web application [/Spring.MVC] 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.
Sep 06, 2014 8:31:55 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
WARNING: The web application [/Spring.MVC] 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(Unknown Source)
 com.mysql.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:40)
Sep 06, 2014 8:32:00 PM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Sep 06, 2014 8:32:00 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
Sep 06, 2014 8:32:03 PM org.hibernate.jpa.internal.util.LogHelper logPersistenceUnitInformation
INFO: HHH000204: Processing PersistenceUnitInfo [
    name: personPU
    ...]

지금까지 메모리 누수가 발생하지 않았기 때문에 VisualVM을 확인했지만 모든 것이 평소와 같이 작동합니다. 그러나이 문제에 대해 더 많이 검색 할 때 MySQL 드라이버가 리소스를 해제하지 않았거나 제대로 닫히지 않았기 때문에이 경고가 발생합니다. 정확히 어떻게 말을 해야할지 모르겠다) 그리고 나는이 게시물에서 관련 문제로 끝났다.

OP가 맞다면 "그다지 걱정하지 마십시오"라는 대답은 충분하지 않을 것입니다. 이 경고는 나에게 성가신 문제를 줄 수 있기 때문에 걱정 스럽다. OP가 작성한 코드를 사용해 보았지만이 코드를 작동시키기 위해 라이브러리를 사용해야하는 데는 문제가있다. 이게 내가 멀리서 ..

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 org.hibernate.annotations.common.util.impl.LoggerFactory;
import com.mysql.jdbc.AbandonedConnectionCleanupThread;
@WebListener
public class ContextFinalizer implements ServletContextListener {

private static final Logger LOGGER = LoggerFactory.getLogger(ContextFinalizer.class);

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);
            LOGGER.warn(String.format("Driver %s deregistered", d));
        }
        catch (SQLException ex) {
            LOGGER.warn(String.format("Error deregistering driver %s", d), ex);
        }
    }
    try {
        AbandonedConnectionCleanupThread.shutdown();
    }
    catch (InterruptedException e) {
        logger.warn("SEVERE problem cleaning up: " + e.getMessage());
        e.printStackTrace();
    }
  }
}

도서관에 필요한 라이브러리가 무엇인지 알고 싶습니다. 또는 제대로 구현하기 위해 올바른 라이브러리를 사용하고 있다면 Logger를 사용해야할지 모르겠지만 어떤 도움을 주셔서 감사합니다.

해결법

  1. ==============================

    1.이 대답을보십시오. MySQL 드라이버는 응용 프로그램간에 공유되는 {$ TOMCAT} / lib에 있어야합니다. 각 응용 프로그램에 포함시키지 않았는지 확인하십시오. 적어도 그것은 나를 위해 일했고 나는 경고를 지울 수있었습니다.

    이 대답을보십시오. MySQL 드라이버는 응용 프로그램간에 공유되는 {$ TOMCAT} / lib에 있어야합니다. 각 응용 프로그램에 포함시키지 않았는지 확인하십시오. 적어도 그것은 나를 위해 일했고 나는 경고를 지울 수있었습니다.

    Maven을 사용한다면 제공된 종속성을 표시하십시오.

    최신 정보: 근본 원인은 Tomcat이 여러 응용 프로그램에 공통적 인 싱글 톤에 등록되어 있기 때문에 드라이버를 수집하는 데 문제가 있다는 것입니다. 하나의 응용 프로그램을 닫으면 Tomcat이 드라이버를 릴리스 할 수 없습니다. 이 대답을보십시오.

  2. from https://stackoverflow.com/questions/25699985/the-web-application-appears-to-have-started-a-thread-named-abandoned-connect by cc-by-sa and MIT license