3

When I stop tomcat7.0,I get this.I can't fix it out.Any help will be appreciated.

SEVERE: The web application [/marketservice] registered the JDBC driver[oracle.jdbc.driver.OracleDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
2011-10-13 9:11:27 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/marketservice] appears to have started a thread named [FileWatchdog] but has failed to stop it. This is very likely to create a memory leak.
2011-10-13 9:11:27 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/marketservice] appears to have started a thread named [Timer-0] but has failed to stop it. This is very likely to create a memory leak.
2011-10-13 9:11:27 org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/marketservice] created a ThreadLocal with key of type [com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.opensymphony.xwork2.inject.ContainerImpl$10@e24fa8]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@1dba740]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak. 
2011-10-13 9:11:27 org.apache.coyote.AbstractProtocolHandler stop
INFO: Stopping ProtocolHandler ["http-bio-8080"]
2011-10-13 9:11:27 org.apache.coyote.AbstractProtocolHandler stop
INFO: Stopping ProtocolHandler ["ajp-bio-8009"]
zhray
  • 291
  • 4
  • 5
  • 1
    possible duplicate of [To prevent a memory leak, the JDBC Driver has been forcibly unregistered](http://stackoverflow.com/questions/3320400/to-prevent-a-memory-leak-the-jdbc-driver-has-been-forcibly-unregistered) – BalusC Oct 13 '11 at 02:07

1 Answers1

1

I know your topic is not brand new any more but any ways I've got the same problem with the WatchDog

(The part with the JDBC connection is already solved: link to Tomcat wiki)

appears to have started a thread named [FileWatchdog] but has failed to stop it. This is very likely to create a memory leak.

They try hard to fix it in one of the next releases of log4j link to log4j bug parade

But I think there is a way around. I start the "WatchDog" like this:

@PostConstruct  
private void initLogging(File log4JConfig) {

    if (loggingExecutor == null) {
        LogManager.resetConfiguration();
        XMLWatchdog xdog = new XMLWatchdog(log4JConfig.getAbsolutePath());
        loggingExecutor = Executors.newSingleThreadScheduledExecutor();

        loggingExecutor.scheduleAtFixedRate(xdog, 0, 5, TimeUnit.MINUTES);
        Logger logger = Logger.getLogger(ConfigurationService.class);
        logger.info("Logging is initialized with the following configuration file: " + log4JConfig.getAbsolutePath());
    } else {
        logger.info("Logger is already ruinning");
    }

}

/**
 * Nasty bug:
 * 
 * https://issues.apache.org/bugzilla/show_bug.cgi?id=4913
 * 
 * 
 * @author Johannes.Hoehne
 * 
 */
private static class XMLWatchdog extends FileWatchdog {

    XMLWatchdog(String filename) {
        super(filename);
        setName("LogFileChecker");
    }

    public void doOnChange() {
        new DOMConfigurator().doConfigure(filename, LogManager.getLoggerRepository());
    }

    @Override
    public void run() {
        checkAndConfigure();
    }
}

And stop it afterwards again like this

    @PreDestroy
public void shutDownLogger() {
    logger.info("Will shut down logger task " + loggingExecutor);
    loggingExecutor.shutdown();
}
JohannesH
  • 33
  • 1
  • 5