在使用Jfinal 2.0 的整合一个定时任务的插件后 。将工程打包 ,部署到Tomcat,启动之后 ,控制台就会报错,显示是在Tomcat 关闭的时候有线程未被关闭,会导致内存溢出,完整报错信息如下:
三月 05, 2017 3:04:50 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server version: Apache Tomcat/7.0.61
三月 05, 2017 3:04:50 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server built: Mar 27 2015 12:03:56 UTC
三月 05, 2017 3:04:50 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server number: 7.0.61.0
三月 05, 2017 3:04:50 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Name: Windows 10
三月 05, 2017 3:04:50 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Version: 10.0
三月 05, 2017 3:04:50 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Architecture: amd64
三月 05, 2017 3:04:50 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Java Home: D:\softposition\java\jdk_1.8.0_111\jre
三月 05, 2017 3:04:50 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Version: 1.8.0_111-b14
三月 05, 2017 3:04:50 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Vendor: Oracle Corporation
三月 05, 2017 3:04:50 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_BASE: D:\apache-tomcat-7.0.61
三月 05, 2017 3:04:50 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_HOME: D:\apache-tomcat-7.0.61
三月 05, 2017 3:04:50 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.util.logging.config.file=D:\apache-tomcat-7.0.61\conf\logging.properties
三月 05, 2017 3:04:50 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
三月 05, 2017 3:04:50 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.endorsed.dirs=D:\apache-tomcat-7.0.61\endorsed
三月 05, 2017 3:04:50 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.base=D:\apache-tomcat-7.0.61
三月 05, 2017 3:04:50 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.home=D:\apache-tomcat-7.0.61
三月 05, 2017 3:04:50 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.io.tmpdir=D:\apache-tomcat-7.0.61\temp
三月 05, 2017 3:04:50 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: Loaded APR based Apache Tomcat Native library 1.1.33 using APR version 1.5.1.
三月 05, 2017 3:04:50 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
三月 05, 2017 3:04:50 下午 org.apache.catalina.core.AprLifecycleListener initializeSSL
信息: OpenSSL successfully initialized (OpenSSL 1.0.1m 19 Mar 2015)
三月 05, 2017 3:04:50 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["http-apr-80"]
三月 05, 2017 3:04:50 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["ajp-apr-8009"]
三月 05, 2017 3:04:50 下午 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 1150 ms
三月 05, 2017 3:04:50 下午 org.apache.catalina.core.StandardService startInternal
信息: Starting service Catalina
三月 05, 2017 3:04:50 下午 org.apache.catalina.core.StandardEngine startInternal
信息: Starting Servlet Engine: Apache Tomcat/7.0.61
三月 05, 2017 3:04:50 下午 org.apache.catalina.startup.HostConfig deployWAR
信息: Deploying web application archive D:\apache-tomcat-7.0.61\webapps\po.war
三月 05, 2017 3:04:51 下午 org.apache.catalina.loader.WebappClassLoader validateJarFile
信息: validateJarFile(D:\apache-tomcat-7.0.61\webapps\po\WEB-INF\lib\javax.servlet-3.0.0.v201112011016.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/servlet/Servlet.class
三月 05, 2017 3:04:52 下午 org.apache.catalina.startup.TaglibUriRule body
信息: TLD skipped. URI: http://shiro.apache.org/tags is already defined
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
log4j:WARN No appenders could be found for logger (org.apache.commons.beanutils.converters.BooleanConverter).
log4j:WARN Please initialize the log4j system properly.
三月 05, 2017 3:04:54 下午 org.apache.catalina.core.StandardContext startInternal
严重: Error filterStart
三月 05, 2017 3:04:54 下午 org.apache.catalina.core.StandardContext startInternal
严重: Context [/po] startup failed due to previous eWebappClassLoader clearReferencesJdbc
严重: The web application [/po] registered the JDBC driver [com.alibaba.druid.proxy.DruidDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
三月 05, 2017 3:04:59 下午 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
严重: The web application [/po] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
三月 05, 2017 3:04:59 下午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/po] appears to have started a thread named [Druid-ConnectionPool-Create-1964019847] but has failed to stop it. This is very likely to create a memory leak.
三月 05, 2017 3:04:59 下午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/po] appears to have started a thread named [Druid-ConnectionPool-Destroy-1964019847] but has failed to stop it. This is very likely to create a memory leak.
三月 05, 2017 3:04:59 下午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/po] 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.
三月 05, 2017 3:04:59 下午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/po] appears to have started a thread named [DefaultQuartzScheduler_Worker-2] but has failed to stop it. This is very likely to create a memory leak.
三月 05, 2017 3:04:59 下午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/po] appears to have started a thread named [DefaultQuartzScheduler_Worker-3] but has failed to stop it. This is very likely to create a memory leak.
三月 05, 2017 3:04:59 下午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/po] appears to have started a thread named [DefaultQuartzScheduler_Worker-4] but has failed to stop it. This is very likely to create a memory leak.
三月 05, 2017 3:04:59 下午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/po] appears to have started a thread named [DefaultQuartzScheduler_Worker-5] but has failed to stop it. This is very likely to create a memory leak.
三月 05, 2017 3:04:59 下午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/po] appears to have started a thread named [DefaultQuartzScheduler_Worker-6] but has failed to stop it. This is very likely to create a memory leak.
三月 05, 2017 3:04:59 下午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/po] appears to have started a thread named [DefaultQuartzScheduler_Worker-7] but has failed to stop it. This is very likely to create a memory leak.
三月 05, 2017 3:04:59 下午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/po] appears to have started a thread named [DefaultQuartzScheduler_Worker-8] but has failed to stop it. This is very likely to create a memory leak.
三月 05, 2017 3:04:59 下午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/po] appears to have started a thread named [DefaultQuartzScheduler_Worker-9] but has failed to stop it. This is very likely to create a memory leak.
三月 05, 2017 3:04:59 下午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/po] appears to have started a thread named [DefaultQuartzScheduler_Worker-10] but has failed to stop it. This is very likely to create a memory leak.
三月 05, 2017 3:04:59 下午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/po] appears to have started a thread named [Timer-0] but has failed to stop it. This is very likely to create a memory leak.
三月 05, 2017 3:04:59 下午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/po] appears to have started a thread named [DefaultQuartzScheduler_QuartzSchedulerThread] but has failed to stop it. This is very likely to create a memory leak.
三月 05, 2017 3:04:59 下午 org.apache.catalina.startup.HostConfig deployWAR
信息: Deployment of web application archive D:\apache-tomcat-7.0.61\webapps\po.war has finished in 8,323 ms
三月 05, 2017 3:04:59 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory D:\apache-tomcat-7.0.61\webapps\docs
三月 05, 2017 3:04:59 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deployment of web application directory D:\apache-tomcat-7.0.61\webapps\docs has finished in 63 ms
三月 05, 2017 3:04:59 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory D:\apache-tomcat-7.0.61\webapps\examples
三月 05, 2017 3:04:59 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deployment of web application directory D:\apache-tomcat-7.0.61\webapps\examples has finished in 250 ms
三月 05, 2017 3:04:59 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory D:\apache-tomcat-7.0.61\webapps\host-manager
三月 05, 2017 3:04:59 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deployment of web application directory D:\apache-tomcat-7.0.61\webapps\host-manager has finished in 47 ms
三月 05, 2017 3:04:59 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory D:\apache-tomcat-7.0.61\webapps\manager
三月 05, 2017 3:04:59 下午 org.apache.catalina.startuprrors
三月 05, 2017 3:04:59 下午 org.apache.catalina.loader..HostConfig deployDirectory
信息: Deployment of web application directory D:\apache-tomcat-7.0.61\webapps\manager has finished in 62 ms
三月 05, 2017 3:04:59 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["http-apr-80"]
三月 05, 2017 3:04:59 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["ajp-apr-8009"]
三月 05, 2017 3:04:59 下午 org.apache.catalina.startup.Catalina start
信息: Server startup in 8834 ms
这种情况,通常是由于在项目之中存在非 daemon 类型的线程,所以在 tomcat 使用 shutdown 命令时并不能真正关闭 tomcat
解决办法极其简单,找到那个非 daemon 线程,将其改为 daemon 线程即可。寻找的办法可以是在 eclipse 时启动项目,观察所有启动的线程类型即可知道