Tomcat 6中的Quartz调度程序,线程不会停止
对于我的网络应用程序,我使用 Quartz。当我部署应用程序时一切正常。当我取消部署应用程序时,Quartz 线程不会被破坏。
日志是:
信息:停止服务 Catalina
严重:网络应用程序 [/example] 似乎已经开始了 线程名为 [DefaultQuartzScheduler_Worker-1]但是 却未能阻止它。这是非常 可能会造成内存泄漏。七月 2010 年 12 月 6:30:40 org.apache.catalina.loader.WebappClassLoader 清除参考线程
任何人都可以告诉我如何强制执行这些线程的销毁操作?
谢谢,
托马索
for my webapp I use Quartz. When I deploy the app all is ok. When I undeploy the app, the Quartz thread is not destroyed.
Log is:
INFO: Stopping service Catalina
SEVERE: The web application
[/example] appears to have started a
thread named
[DefaultQuartzScheduler_Worker-1] but
has failed to stop it. This is very
likely to create a memory leak. Jul
12, 2010 6:30:40 PM
org.apache.catalina.loader.WebappClassLoader
clearReferencesThreads
Anyone can tell me how I can force the destroy action for those threads?
Thanks,
Tommaso
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我发现对我来说问题是quartz正在关闭,但是web应用程序没有等待quartz完成就关闭了,所以Tomcat认为它让线程保持运行并抱怨。
所以我这样管理我的调度程序:
注意 关闭是重要部分。如果您删除该
true
以调用无参数版本或将其设置为false
,您的 Web 应用程序将不会等待quartz 关闭而关闭。TL;DR:调用
scheduler.shutdown(true)
让您的 Web 应用程序等待 Quartz 完成。I found that the issue for me was that quartz was being shutdown but the webapp didn't wait for quartz to finish before it shutdown so Tomcat decided that it had left threads running and complained.
So I managed my scheduler like this:
Note the boolean argument to shutdown is the vital part. If you remove that
true
to call the no-arg version or set it tofalse
, your webapp won't wait for quartz to shudown before it shuts down.TL;DR: call
scheduler.shutdown(true)
to make your webapp wait for quartz to finish.你是如何启动石英的?
假设您没有使用像 Spring 这样方便的包装器,您可能希望在应用程序的 web.xml 中使用
,以便可以通知 Quartz 应用程序启动和< /em> 关闭。请参阅 QuartzInitializerListener 或 QuartzInitializerServlet 。
How are you starting Quartz?
Assuming you are not using a convenient wrapper like Spring, you probably want to be using a
<listener>
in your application's web.xml so that Quartz can be notified of the application start and shutdown.See QuartzInitializerListener or QuartzInitializerServlet for instance.
我建议您使用 2.x 版本,并向
web.xml
添加侦听器。将以下方法添加到监听器中:
I recommend you to use the 2.x version and, add a listener to
web.xml
.Add the method below to the listener: