停止tomcat,定时任务无法关闭

--------------------------------------------------------------------------------
G:\apache-tomcat-8.5.35-windows-x64\apache-tomcat-8.5.35\bin\catalina.bat?stop
Using?CATALINA_BASE:???"C:\Users\Administrator\.IntelliJIdea2018.3\system\tomcat\Unnamed_ydfxy"
Using?CATALINA_HOME:???"G:\apache-tomcat-8.5.35-windows-x64\apache-tomcat-8.5.35"
Using?CATALINA_TMPDIR:?"G:\apache-tomcat-8.5.35-windows-x64\apache-tomcat-8.5.35\temp"
Using?JRE_HOME:????????"C:\Program?Files\Java\jdk1.8.0_191"
Using?CLASSPATH:???????"G:\apache-tomcat-8.5.35-windows-x64\apache-tomcat-8.5.35\bin\bootstrap.jar;G:\apache-tomcat-8.5.35-windows-x64\apache-tomcat-8.5.35\bin\tomcat-juli.jar"
02-Sep-2019?16:50:49.063?信息?[main]?org.apache.catalina.core.StandardServer.await?A?valid?shutdown?command?was?received?via?the?shutdown?port.?Stopping?the?Server?instance.
02-Sep-2019?16:50:49.064?信息?[main]?org.apache.coyote.AbstractProtocol.pause?Pausing?ProtocolHandler?["http-nio-8090"]
02-Sep-2019?16:50:50.388?信息?[main]?org.apache.coyote.AbstractProtocol.pause?Pausing?ProtocolHandler?["ajp-nio-8009"]
02-Sep-2019?16:50:51.743?信息?[main]?org.apache.catalina.core.StandardService.stopInternal?Stopping?service?[Catalina]
Plugin?stop?error:?cn.dreampie.quartz.QuartzPlugin
Plugin?stop?error:?cn.dreampie.quartz.QuartzPlugin
Plugin?stop?error:?cn.dreampie.quartz.QuartzPlugin

2019-09-02?16:50:51
Plugin?stop?error:?cn.dreampie.quartz.QuartzPlugin
?[]?[]?[ERROR]-[Thread:?localhost-startStop-2]-[com.jfinal.kit.LogKit.error()]:?Can't?stop?quartz?plugin.
Plugin?stop?error:?cn.dreampie.quartz.QuartzPlugin
java.lang.RuntimeException:?Can't?stop?quartz?plugin.
	at?cn.dreampie.quartz.QuartzPlugin.stop(QuartzPlugin.java:65)
	at?com.jfinal.core.JFinal.stopPlugins(JFinal.java:110)
	at?com.jfinal.core.JFinalFilter.destroy(JFinalFilter.java:87)
	at?org.apache.catalina.core.ApplicationFilterConfig.release(ApplicationFilterConfig.java:318)
	at?org.apache.catalina.core.StandardContext.filterStop(StandardContext.java:4670)
	at?org.apache.catalina.core.StandardContext.__stop(StandardContext.java:5470)
	at?org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:46004)
	at?org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:226)
	at?org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1439)
	at?org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1428)
	at?java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at?java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at?java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at?java.lang.Thread.run(Thread.java:748)
Caused?by:?java.lang.NullPointerException
	at?cn.dreampie.quartz.QuartzPlugin.stop(QuartzPlugin.java:61)
	...?13?more

2019-09-02?16:50:51
?[]?[]?[ERROR]-[Thread:?localhost-startStop-2]-[com.jfinal.kit.LogKit.error()]:?Can't?stop?quartz?plugin.
java.lang.RuntimeException:?Can't?stop?quartz?plugin.
	at?cn.dreampie.quartz.QuartzPlugin.stop(QuartzPlugin.java:65)
	at?com.jfinal.core.JFinal.stopPlugins(JFinal.java:110)
	at?com.jfinal.core.JFinalFilter.destroy(JFinalFilter.java:87)
	at?org.apache.catalina.core.ApplicationFilterConfig.release(ApplicationFilterConfig.java:318)
	at?org.apache.catalina.core.StandardContext.filterStop(StandardContext.java:4670)
	at?org.apache.catalina.core.StandardContext.__stop(StandardContext.java:5470)
Plugin?stop?error:?cn.dreampie.quartz.QuartzPlugin
	at?org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:46004)
	at?org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:226)
	at?org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1439)
	at?org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1428)
	at?java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at?java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at?java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at?java.lang.Thread.run(Thread.java:748)
Caused?by:?java.lang.NullPointerException
	at?cn.dreampie.quartz.QuartzPlugin.stop(QuartzPlugin.java:61)
	...?13?more

2019-09-02?16:50:51
?[]?[]?[ERROR]-[Thread:?localhost-startStop-2]-[com.jfinal.kit.LogKit.error()]:?Can't?stop?quartz?plugin.
java.lang.RuntimeException:?Can't?stop?quartz?plugin.
	at?cn.dreampie.quartz.QuartzPlugin.stop(QuartzPlugin.java:65)
	at?com.jfinal.core.JFinal.stopPlugins(JFinal.java:110)
	at?com.jfinal.core.JFinalFilter.destroy(JFinalFilter.java:87)
	at?org.apache.catalina.core.ApplicationFilterConfig.release(ApplicationFilterConfig.java:318)
	at?org.apache.catalina.core.StandardContext.filterStop(StandardContext.java:4670)
	at?org.apache.catalina.core.StandardContext.__stop(StandardContext.java:5470)
	at?org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:46004)
	at?org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:226)
	at?org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1439)
	at?org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1428)
	at?java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at?java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at?java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at?java.lang.Thread.run(Thread.java:748)
Caused?by:?java.lang.NullPointerException
	at?cn.dreampie.quartz.QuartzPlugin.stop(QuartzPlugin.java:61)
	...?13?more

2019-09-02?16:50:51
?[]?[]?[ERROR]-[Thread:?localhost-startStop-2]-[com.jfinal.kit.LogKit.error()]:?Can't?stop?quartz?plugin.
java.lang.RuntimeException:?Can't?stop?quartz?plugin.
	at?cn.dreampie.quartz.QuartzPlugin.stop(QuartzPlugin.java:65)
	at?com.jfinal.core.JFinal.stopPlugins(JFinal.java:110)
	at?com.jfinal.core.JFinalFilter.destroy(JFinalFilter.java:87)
	at?org.apache.catalina.core.ApplicationFilterConfig.release(ApplicationFilterConfig.java:318)
	at?org.apache.catalina.core.StandardContext.filterStop(StandardContext.java:4670)
	at?org.apache.catalina.core.StandardContext.__stop(StandardContext.java:5470)
	at?org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:46004)
	at?org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:226)
	at?org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1439)
	at?org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1428)
	at?java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at?java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at?java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at?java.lang.Thread.run(Thread.java:748)
Caused?by:?java.lang.NullPointerException
	at?cn.dreampie.quartz.QuartzPlugin.stop(QuartzPlugin.java:61)
	...?13?more

2019-09-02?16:50:51
?[]?[]?[ERROR]-[Thread:?localhost-startStop-2]-[com.jfinal.kit.LogKit.error()]:?Can't?stop?quartz?plugin.
java.lang.RuntimeException:?Can't?stop?quartz?plugin.
	at?cn.dreampie.quartz.QuartzPlugin.stop(QuartzPlugin.java:65)
	at?com.jfinal.core.JFinal.stopPlugins(JFinal.java:110)
	at?com.jfinal.core.JFinalFilter.destroy(JFinalFilter.java:87)
	at?org.apache.catalina.core.ApplicationFilterConfig.release(ApplicationFilterConfig.java:318)
	at?org.apache.catalina.core.StandardContext.filterStop(StandardContext.java:4670)
	at?org.apache.catalina.core.StandardContext.__stop(StandardContext.java:5470)
	at?org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:46004)
	at?org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:226)
	at?org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1439)
	at?org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1428)
	at?java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at?java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at?java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at?java.lang.Thread.run(Thread.java:748)
Caused?by:?java.lang.NullPointerException
	at?cn.dreampie.quartz.QuartzPlugin.stop(QuartzPlugin.java:61)
	...?13?more

2019-09-02?16:50:51
?[]?[]?[ERROR]-[Thread:?localhost-startStop-2]-[com.jfinal.kit.LogKit.error()]:?Can't?stop?quartz?plugin.
java.lang.RuntimeException:?Can't?stop?quartz?plugin.
	at?cn.dreampie.quartz.QuartzPlugin.stop(QuartzPlugin.java:65)
	at?com.jfinal.core.JFinal.stopPlugins(JFinal.java:110)
	at?com.jfinal.core.JFinalFilter.destroy(JFinalFilter.java:87)
	at?org.apache.catalina.core.ApplicationFilterConfig.release(ApplicationFilterConfig.java:318)
	at?org.apache.catalina.core.StandardContext.filterStop(StandardContext.java:4670)
	at?org.apache.catalina.core.StandardContext.__stop(StandardContext.java:5470)
	at?org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:46004)
	at?org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:226)
	at?org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1439)
	at?org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1428)
	at?java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at?java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at?java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at?java.lang.Thread.run(Thread.java:748)
Caused?by:?java.lang.NullPointerException
	at?cn.dreampie.quartz.QuartzPlugin.stop(QuartzPlugin.java:61)
	...?13?more
02-Sep-2019?16:50:52.037?信息?[main]?org.apache.coyote.AbstractProtocol.stop?Stopping?ProtocolHandler?["http-nio-8090"]
02-Sep-2019?16:50:52.041?信息?[main]?org.apache.coyote.AbstractProtocol.stop?Stopping?ProtocolHandler?["ajp-nio-8009"]
02-Sep-2019?16:50:52.044?信息?[main]?org.apache.coyote.AbstractProtocol.destroy?Destroying?ProtocolHandler?["http-nio-8090"]
02-Sep-2019?16:50:52.046?信息?[main]?org.apache.coyote.AbstractProtocol.destroy?Destroying?ProtocolHandler?["ajp-nio-8009"]
Disconnected?from?server


评论区

洛小风

2019-09-02 16:59
@JFinal 最近项目刚部署到服务器,运行在tomcat上,然后每天的java内存都持续升高,怀疑是定时任务的锅...

洛小风

2019-09-02 17:04
因为有时候要重启tomcat,但是定时任务关不掉,然后就一直占用线程.这是我的猜想....主要为什么关闭tomcat,会报这么些错

洛小风

2019-09-02 17:35
问题是以前也不会这样,开启一个定时任务也不会这样,开启大于一个,就这样报错了
然后一直占用线程...
内存持续升高..
不知道咋办;了

洛小风

2019-09-02 18:18
@JFinal 能不能稍微帮我看一下.............很奇怪,开启一个定时任务,不论哪个定时任务就不会报错,开启多个定时任务,关闭的时候就不行了.

JFinal

2019-09-02 21:37
cn.dreampie.quartz.QuartzPlugin 这个插件无法 stop(),检查两个问题:
1:是不是空指针异常造成的,有则先解决这个异常
2:是不是 QuartzPlugin 创建的线程不是 daemon 线程

参考 jfinal 官方的 Cron4jPlugin 任务调度插件,里头就是 daemon 线程,停掉 tomcat 的时候才可以 stop() 掉它

此外,建议使用 jfinal undertow, tomcat 太古老了

洛小风

2019-09-04 09:42
@JFinal 谢谢波总的回答,让我去了解到守护线程和用户线程的区别,我现在先改用了Cron4jPlugin 任务调度插件.不过百度的人说守护线程不要做数据的增改逻辑判断等,以防止操作没执行完就退出了.那么我是不是不能用Cron4jPlugin做数据操作了....