appears to have started a thread named [Quartz Scheduler [scheduler]] but has fa
javaweb部署在tomcat中,热部署时会出现以下问题
严重: The web application [/qms] appears to have started a thread named [scheduler_Worker-1] but has failed to stop it. This is very likely to create a memory leak.
2017-11-16 15:06:30 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/qms] appears to have started a thread named [scheduler_Worker-2] but has failed to stop it. This is very likely to create a memory leak.
2017-11-16 15:06:30 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/qms] appears to have started a thread named [scheduler_Worker-3] but has failed to stop it. This is very likely to create a memory leak.
我按照网上说的操作
public class SchedulerFactoryBeanWithShutdownDelay extends SchedulerFactoryBean {
/**
* 关于Quartz内存泄漏的不太美观的解决方案:
* 在调用scheduler.shutdown(true)后增加延时,等待worker线程结束。
*/
@Override
public void destroy() throws SchedulerException {
super.destroy();
// if(this.getScheduler().isInStandbyMode()|| this.getScheduler().isStarted()){
// this.getScheduler().shutdown(true);
// }
//
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
public class QuartzLitener implements ServletContextListener{
@Override
public void contextDestroyed(ServletContextEvent arg0)
{
try
{
ApplicationContext context =CommonsUtils.getApplicationContext();
Scheduler scheduler = (Scheduler) context.getBean("scheduler");
if(scheduler.isStarted()||scheduler.isInStandbyMode()){
scheduler.shutdown(true);
}
// Sleep for a bit so that we don't get any errors
Thread.sleep(30000);
}
catch (Exception e)
{
e.printStackTrace();
}
}
@Override
public void contextInitialized(ServletContextEvent arg0)
{
// ServletContext application =arg0.getServletContext();
// WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(application);
// Scheduler scheduler = (Scheduler) context.getBean("scheduler");
// try {
// scheduler.start();
// } catch (SchedulerException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
}
这个错误 [scheduler_Worker-1] but has failed to stop it 没有出现了
但是还是出现了下面的错误
appears to have started a thread named [Quartz Scheduler [scheduler]] but has failed to stop it. This is very likely to create a memory leak.
这个无法关闭,有什么好的解决办法