当我使用Quartz 2.x运行我的Web应用程序时收到此消息。它运行正常但我在说服务器
时遇到此错误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.
任何帮助表示感谢。
答案 0 :(得分:2)
这可能是由于在Tomcat关闭或Web应用程序重新部署时没有关闭Quartz调度程序(很可能是您的情况)。
您需要实现一个ServletContextListener,并在其contextDestroyed方法中需要执行此操作:
scheduler.shutdown( true ); // true = wait for jobs to complete
// you may want to give Quartz some extra time to shutdown
//Thread.sleep(1000);
您可能还希望配置Quartz线程池以将其线程标记为"守护程序线程" (org.quartz.threadPool.makeThreadsDaemons = true)因为它们不会阻止JVM停止。否则,JVM将等待所有这些工作线程完成。