Yanni
Yanni

Reputation: 103

Quartz2.x: GRAVE: The web application [/servlet] appears to have started a thread named [Thread-4] but has failed to stop it

I am getting this message when I run my web application with Quartz 2.x . It runs fine but I get this error during stating server

INFO: Server startup in 1792 ms
20 mai 2014 18:18:59 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
GRAVE: The web application [/servlet] appears to have started a thread named [Thread-4] but has failed to stop it. This is very likely to create a memory leak.
20 mai 2014 18:18:59 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
GRAVE: The web application [/servlet] appears to have started a thread named [CronTriggers_Worker-1] but has failed to stop it. This is very likely to create a memory leak.
20 mai 2014 18:18:59 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
GRAVE: The web application [/servlet] appears to have started a thread named [CronTriggers_Worker-2] but has failed to stop it. This is very likely to create a memory leak.

Any help appreciated.

Upvotes: 1

Views: 1585

Answers (1)

Jan Moravec
Jan Moravec

Reputation: 1880

This may be caused by not shutting down the Quartz scheduler upon Tomcat shutdown or web-application redeploy (most likely your case).

You will need to implement a ServletContextListener and in its contextDestroyed method you will need to do this:

scheduler.shutdown( true );  // true = wait for jobs to complete
// you may want to give Quartz some extra time to shutdown
//Thread.sleep(1000);

You may also want to configure the Quartz thread-pool to mark its threads as "daemon threads" (org.quartz.threadPool.makeThreadsDaemons=true) as they will not block the JVM from stopping. Otherwise, the JVM will wait for all these worker threads to finish.

Upvotes: 2

Related Questions