tomcat-quartz appears to have started a thread named [startQuertz_Worker-1] but has failed to stop i
来源:互联网 发布:笔记本按ubuntu黑屏 编辑:程序博客网 时间:2023/12/10 21:45
在tomcat7+quartz1.8/1.7 + spring3.0.5做定时任务的时候 , 当关闭tomcat时会发现如下异常:
ar 27, 2013 6:05:35 PM org.apache.coyote.AbstractProtocol pauseINFO: Pausing ProtocolHandler ["http-nio-8082"]Mar 27, 2013 6:05:35 PM org.apache.catalina.core.StandardService stopInternalINFO: Stopping service CatalinaMar 27, 2013 6:05:35 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreadsSEVERE: The web application [/****] appears to have started a thread named [startQuertz_Worker-1] buthas failed to stop it. This is very likely to create a memory leak.Mar 27, 2013 6:05:35 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreadsSEVERE: The web application [/****] appears to have started a thread named [startQuertz_Worker-2] buthas failed to stop it. This is very likely to create a memory leak.Mar 27, 2013 6:05:35 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreadsSEVERE: The web application [/****] appears to have started a thread named [startQuertz_Worker-3] buthas failed to stop it. This is very likely to create a memory leak.Mar 27, 2013 6:05:35 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
首先怀疑线程泄漏 , 依各位前辈的经验建议 , 修改quartz的配置:
<bean id="startQuertz" lazy-init="false" autowire="no"class="org.springframework.scheduling.quartz.SchedulerFactoryBean"><property name="triggers"><list></list></property><property name="quartzProperties"> <props> <prop key="org.quartz.scheduler.instanceName">buy_it_now</prop> <prop key="org.quartz.threadPool.threadCount">2</prop> <prop key="org.quartz.plugin.shutdownhook.class">org.quartz.plugins.management.ShutdownHookPlugin</prop> <prop key="org.quartz.plugin.shutdownhook.cleanShutdown">true</prop> <prop key="org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread">true</prop> </props> </property>未果 , 以上配置只是设置了线程池的大小和在shutdown时进行清理 , 结果在老外的网站上发现了解决办法。
日志warn可能线程泄漏 ,但事实并非如此(本人没考证) , 只是tomcat在shutdown做清理工作的时候没能等待quartz完成cleanShutdown !就是tomcat太心急了 , 说 “quartz , 我关门了 , 你走吧!” , 还没等quartz反应过来,
就要关大门 , 这时发现 “quartz , 你怎么还在这儿呀!”。 解决的办法简单:自己实现一个ServletContextListener ,
在contextDestroyed的时候主动调用quartz schedular的shutdown方法 ,并且主线程sleep一会儿 , 上例子:
public class QuartzContextListener implements ServletContextListener {/* * 测试代码写得随便 * * @seejavax.servlet.ServletContextListener#contextDestroyed(javax.servlet. * ServletContextEvent) */@Overridepublic void contextDestroyed(ServletContextEvent arg0) {WebApplicationContext webApplicationContext = (WebApplicationContext) arg0.getServletContext().getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);org.quartz.impl.StdScheduler startQuertz = (org.quartz.impl.StdScheduler) webApplicationContext.getBean("startQuertz");if(startQuertz != null) {startQuertz.shutdown();}try {Thread.sleep(1000);} catch (InterruptedException e) {e.printStackTrace();}}/* * (non-Javadoc) * * @see * javax.servlet.ServletContextListener#contextInitialized(javax.servlet * .ServletContextEvent) */@Overridepublic void contextInitialized(ServletContextEvent arg0) {//不做任何事情}}
别忘了web.xml中添加起! 结束
- tomcat-quartz appears to have started a thread named [startQuertz_Worker-1] but has failed to stop i
- appears to have started a thread named [startQuertz_xxx] but has failed to stop it. This is very...
- a thread named [Abandoned connection cleanup thread] but has failed to stop it
- 关闭Tomcat报错The web application [ROOT] appears to have started a thread named [Abandoned connectio
- 异常:“严重: The web application [] appears to have started a thread named [Thread-”
- 严重: The web application [] appears to have started a thread named [Thread-
- The web application [] appears to have started a thread named [Thread-
- The web application [/jenkins] appears to have started a thread named [Executor [问题点数:20分]
- 严重:The web application [web01] appears to have started a thread named ...
- Tomcat 报错:The web application [XXX] appears to have started a thread...
- quartz 集群出现问题([DefaultQuartzScheduler_Worker-1] but has failed to stop it.)
- Tomcat-shutdown.sh报错but has failed to stop it. This is very likely to create a memory leak.
- quartzScheduler_Worker-1] but has failed to stop it. This is very likely to create a memory leak解决
- The web application [] appears to have started ...
- but has failed to stop it. This is very likely to create a memory leak(c3p0在Spring管理中,连接未关闭导致的内存溢出)
- How to Stop a Thread
- I have a bad habit but I wasn't meant to do
- There appears to be a gap in the edit log. We expected txid 1, but got txid 16
- ibm competency
- linux设备驱动归纳总结(十一):写个简单的看门狗驱动
- select、poll、epoll的比较
- iOS对象序列化 .
- Ubuntu_搭建Lua安装环境
- tomcat-quartz appears to have started a thread named [startQuertz_Worker-1] but has failed to stop i
- 【Android 工具】TraceView使用方法
- 人生无根蒂,飘如陌上尘.
- 解决【FastCGI 进程超过了配置的活动超时时限】
- 人生无根蒂,飘如陌上尘.
- 【Android 工具】Monkey工具 (自动化压力测试)
- ios 使用已经知道到的日期,获取时间
- linux设备驱动归纳总结(十二):简单的数码相框
- How to get a 64-bit compiler under windows to use with matlab