appears to have started a thread named [Quartz Scheduler [scheduler]] but has fa

zhouyusunquan 2017-12-27 10:11:15
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.

这个无法关闭,有什么好的解决办法
...全文
2379 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
牵着蚂蚁散步 2018-03-19
  • 打赏
  • 举报
回复
貌似没有什么卵用

81,094

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧