使用tomcat部署多个项目时, 启动莫名其妙的错, schedulerFactory_Worker-1 memory leak.

又是一个奇葩的错误.

如题, 不多说, 先上日志..

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
30-Dec-2015 11:11:17.303 SEVERE [crm.huajichina.com-startStop-1] org.apache.catalina.core.StandardContext.startInternal Error listenerStart
30-Dec-2015 11:11:17.305 SEVERE [crm.huajichina.com-startStop-1] org.apache.catalina.core.StandardContext.startInternal Context [/crm] startup failed due to previous errors
30-Dec-2015 11:11:17.307 INFO [crm.huajichina.com-startStop-1] com.sun.xml.ws.transport.http.servlet.WSServletDelegate.destroy WSSERVLET15: JAX-WS servlet 已销毁
30-Dec-2015 11:11:17.311 INFO [crm.huajichina.com-startStop-1] com.sun.xml.ws.transport.http.servlet.WSServletContextListener.contextDestroyed WSSERVLET13: JAX-WS 上下文监听程序已销毁
30-Dec-2015 11:11:17.312 INFO [crm.huajichina.com-startStop-1] com.sun.xml.ws.transport.http.servlet.WSServletContextListener.contextDestroyed WSSERVLET13: JAX-WS 上下文监听程序已销毁
30-Dec-2015 11:11:17.317 INFO [crm.huajichina.com-startStop-1] org.apache.catalina.core.ApplicationContext.log Closing Spring root WebApplicationContext
30-Dec-2015 11:11:17.349 INFO [crm.huajichina.com-startStop-1] org.apache.catalina.core.ApplicationContext.log Shutting down log4j
30-Dec-2015 11:11:17.402 WARNING [crm.huajichina.com-startStop-1] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesJdbc The web application [crm] 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.
30-Dec-2015 11:11:17.469 WARNING [crm.huajichina.com-startStop-1] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [crm] appears to have started a thread named [schedulerFactory_Worker-1] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:519)
30-Dec-2015 11:11:17.492 WARNING [crm.huajichina.com-startStop-1] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [crm] appears to have started a thread named [pool-1-thread-1] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
sun.misc.Unsafe.park(Native Method)
java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)
java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1093)
java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809)
java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
java.lang.Thread.run(Thread.java:745)
30-Dec-2015 11:11:17.589 WARNING [crm.huajichina.com-startStop-1] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [crm] appears to have started a thread named [MySQL Statement Cancellation Timer] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
java.util.TimerThread.mainLoop(Timer.java:552)
java.util.TimerThread.run(Timer.java:505)
30-Dec-2015 11:11:17.601 WARNING [crm.huajichina.com-startStop-1] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [crm] appears to have started a thread named [com.google.common.base.internal.Finalizer] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143)
java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:164)
com.google.common.base.internal.Finalizer.run(Finalizer.java:127)
30-Dec-2015 11:11:17.604 WARNING [crm.huajichina.com-startStop-1] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [crm] appears to have started a thread named [BoneCP-release-thread-helper-thread] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
sun.misc.Unsafe.park(Native Method)
java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
jsr166y.LinkedTransferQueue.awaitMatch(LinkedTransferQueue.java:700)
jsr166y.LinkedTransferQueue.xfer(LinkedTransferQueue.java:600)
jsr166y.LinkedTransferQueue.take(LinkedTransferQueue.java:1060)
com.jolbox.bonecp.ConnectionReleaseHelperThread.run(ConnectionReleaseHelperThread.java:76)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
java.lang.Thread.run(Thread.java:745)
30-Dec-2015 11:11:17.614 WARNING [crm.huajichina.com-startStop-1] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [crm] appears to have started a thread named [BoneCP-release-thread-helper-thread] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
sun.misc.Unsafe.park(Native Method)
java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
jsr166y.LinkedTransferQueue.awaitMatch(LinkedTransferQueue.java:700)
jsr166y.LinkedTransferQueue.xfer(LinkedTransferQueue.java:600)
jsr166y.LinkedTransferQueue.take(LinkedTransferQueue.java:1060)
com.jolbox.bonecp.ConnectionReleaseHelperThread.run(ConnectionReleaseHelperThread.java:76)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
java.lang.Thread.run(Thread.java:745)

tomcat里放了两个project, 两个project单独启动任何一个或者分两个tomcat分别启动, 没有任何问题,

但是放到一个tomcat启动, 一个成功启动, 另一个启动失败出现以上错误. 检查各项配置均正常, 无解.:sob::sob::sob:

从日志上看, 根本看不出问题在哪儿. 因前车之鉴 使用ContextLoaderListener监听tomcat启动时, tomcat启动报错 tomcat这里的日志肯定存在缺陷, 只能凭感觉和经验四处查找, 果然, 两日无果.:disappointed:

今天经一友人提醒, 将project移出, tomcat空启动后, 一个一个deploy试试看, 遂从之.

喜从天降, 报错日志信息发生了改变. 终于能看懂了. :joy::joy::joy:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
org.springframework.web.util.Log4jConfigListener
java.lang.IllegalStateException: Web app root system property already set to different value: 'webapp.root' = [/home/apache-tomcat-8.0.15/webapps/store] instead of [/home/apache-tomcat-8.0.15/webapps/crm] - Choose unique values for the 'webAppRootKey' context-param in your web.xml files!
at org.springframework.web.util.WebUtils.setWebAppRootSystemProperty(WebUtils.java:150)
at org.springframework.web.util.Log4jWebConfigurer.initLogging(Log4jWebConfigurer.java:117)
at org.springframework.web.util.Log4jConfigListener.contextInitialized(Log4jConfigListener.java:45)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4772)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5196)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:714)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1069)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1719)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

原来是因为两个project都没有在web.xml中指定项目名, 导致tomcat无法识别. 加上以下配置即可解决.

1
2
3
4
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>xxx.root</param-value>
</context-param>

但是以前貌似我也在一个tomcat里扔过多个project, 但是没有遇到过这个问题, 具体是为什么, 暂时没精力深究了.

至此, 此问题圆满解决. 感谢董显格童鞋的帮助, 帮我分析查看服务器, 费了不少精力, 更是最后一语点醒梦中人, 非常感谢.

文章目录
  1. 1. 又是一个奇葩的错误.
,