首页 > 代码库 > tomcat应用org.apache.catalina.LifecycleException: Failed to stop component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]异常的根本原因

tomcat应用org.apache.catalina.LifecycleException: Failed to stop component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]异常的根本原因

早上,有个应用又挂了,客户端打开时报404,看进程是还在的。倒回第一次异常的地方,可见catalina.out中有如下信息:

08:46:56.646 [ContainerBackgroundProcessor[StandardEngine[Catalina]]] DEBUG o.s.b.f.s.DisposableBeanAdapter - Invoking destroy() on bean with name ‘org.springframework.scheduling.config.ContextLifecycleSchedul
edTaskRegistrar#0‘
08:46:56.647 [ContainerBackgroundProcessor[StandardEngine[Catalina]]] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Retrieved dependent beans for bean ‘(inner bean)#293beccc‘: [org.springframework.aop.aspectj.A
spectJPointcutAdvisor#1]
08:46:56.647 [ContainerBackgroundProcessor[StandardEngine[Catalina]]] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Retrieved dependent beans for bean ‘(inner bean)#debcf58‘: [(inner bean)#293beccc]
08:46:56.647 [ContainerBackgroundProcessor[StandardEngine[Catalina]]] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Retrieved dependent beans for bean ‘(inner bean)#430751d4‘: [org.springframework.aop.aspectj.A
spectJPointcutAdvisor#0]
08:46:56.647 [ContainerBackgroundProcessor[StandardEngine[Catalina]]] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Retrieved dependent beans for bean ‘(inner bean)#429fcab3‘: [(inner bean)#430751d4]
Feb 04, 2017 8:46:56 AM org.apache.catalina.core.StandardContext reload
SEVERE: Exception stopping Context with name []
org.apache.catalina.LifecycleException: Failed to stop component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:236)
at org.apache.catalina.core.StandardContext.reload(StandardContext.java:4090)
at org.apache.catalina.loader.WebappLoader.backgroundProcess(WebappLoader.java:425)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1344)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1545)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1555)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1555)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1523)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.catalina.LifecycleException: Failed to stop component [WebappLoader[]]
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:236)
at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5829)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
... 8 more
Caused by: java.lang.NullPointerException
at org.apache.catalina.loader.WebappClassLoaderBase.findResourceInternal(WebappClassLoaderBase.java:3308)
at org.apache.catalina.loader.WebappClassLoaderBase.findResource(WebappClassLoaderBase.java:1428)
at org.apache.catalina.loader.WebappClassLoaderBase.getResourceAsStream(WebappClassLoaderBase.java:1656)
at org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesJdbc(WebappClassLoaderBase.java:2223)
at org.apache.catalina.loader.WebappClassLoaderBase.clearReferences(WebappClassLoaderBase.java:2166)
at org.apache.catalina.loader.WebappClassLoaderBase.stop(WebappClassLoaderBase.java:2066)
at org.apache.catalina.loader.WebappLoader.stopInternal(WebappLoader.java:661)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
... 10 more

Feb 04, 2017 8:46:56 AM org.apache.catalina.util.LifecycleBase stop
INFO: The stop() method was called on component [org.apache.catalina.deploy.NamingResources@7cb5ad1] after stop() had already been called. The second call will be ignored.
Feb 04, 2017 8:46:56 AM org.apache.catalina.core.StandardContext reload

这比较坑爹的是,好像没有一个属性在server.xml中设置如果某个webapp挂了,tomcat直接退出的。不然的话,如果后面有不受容器管理的操作比如socket连接,将会使得应用日志最后看起来是正常的,但实际上已经挂了。

这里其实看不出为什么应用挂掉的,逐步往后回查(看日志级别为SEVERE的),发现如下错误:

SEVERE: Resource ‘/WEB-INF/lib/slf4j-api-1.7.10.jar‘ is missing
Feb 04, 2017 8:46:56 AM org.apache.catalina.core.StandardContext reload
INFO: Reloading Context with name [] has started

看应用中,1.7.12的版本是有的。

怀疑是 <Context>节点的reloadable设置为"true"造成的,经查,该值确实为true,应该是自动加载期间版本不一致问题所致。

tomcat应用org.apache.catalina.LifecycleException: Failed to stop component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]异常的根本原因