this web application instance has been stopped already异常

tomcat下启动多个应用时可能遇到的异常:

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; background-color: #ffffff}p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; background-color: #ffffff; min-height: 13.0px}span.s1 {font-variant-ligatures: no-common-ligatures}span.Apple-tab-span {white-space:pre}

INFO: Starting ProtocolHandler ["ajp-bio-9009"]
Oct 25, 2016 10:00:26 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 14612 ms
Oct 25, 2016 10:00:27 PM org.apache.catalina.loader.WebappClassLoaderBase loadClass
INFO: Illegal access: this web application instance has been stopped already.  Could not load org.springframework.core.NestedExceptionUtils.  The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
java.lang.IllegalStateException
 at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1745)
 at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1703)
 at org.springframework.core.NestedRuntimeException.<clinit>(NestedRuntimeException.java:45)
 at org.springframework.scheduling.quartz.SchedulerFactoryBean$1.run(SchedulerFactoryBean.java:672)

Exception in thread "Quartz Scheduler [scheduler]" java.lang.NoClassDefFoundError: org/springframework/core/NestedExceptionUtils
 at org.springframework.core.NestedRuntimeException.<clinit>(NestedRuntimeException.java:45)
 at org.springframework.scheduling.quartz.SchedulerFactoryBean$1.run(SchedulerFactoryBean.java:672)
Caused by: java.lang.ClassNotFoundException: org.springframework.core.NestedExceptionUtils
 at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1854)
 at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1703)
 ... 2 more

原因

看日志以为是“com.xxx.xxx.xxxxxxx”类加载异常,其实这个只是现象,不不是真正引起问题的原因。
看这个真正的异常原因需要看tomcat/logs/localhost.年-月-日.log的文件,这个文件中会描述正真的错误原因。

tomcat/logs/localhost.年-月-日.log`的文件

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; background-color: #ffffff}span.s1 {font-variant-ligatures: no-common-ligatures}span.Apple-tab-span {white-space:pre}

Oct 25, 2016 5:00:54 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.util.Log4jConfigListener
java.lang.IllegalStateException: Web app root system property already set to different value: 'webapp.root' = [/home/vhsworkdic/zicai/webapps/cbsService/] instead of [/home/vhsworkdic/zicai/webapps/zicai/] - Choose unique values for the 'webAppRootKey' context-param in your web.xml files!
 at org.springframework.web.util.WebUtils.setWebAppRootSystemProperty(WebUtils.java:151)
 at org.springframework.web.util.Log4jWebConfigurer.initLogging(Log4jWebConfigurer.java:116)
 at org.springframework.web.util.Log4jConfigListener.contextInitialized(Log4jConfigListener.java:45)
 at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5003)
 at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5517)
 at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
 at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
 at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
 at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
 at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1095)
 at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1960)
 at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
 at java.util.concurrent.FutureTask.run(FutureTask.java:262)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
 at java.lang.Thread.run(Thread.java:745)

从日志文件可以看出是说Web应用程序根系统属性已经被设置,’webapp.root’ 这个配置名称已经被使用,提示了Choose unique values for the ‘webAppRootKey’ context-param in your web.xml files ,也就是说在web.xml里配置一个唯一的’webAppRootKey’ ,这样就不会发生冲突。

解决办法

web.xml指定webAppRootKey

<context-param>  
    <param-name>webAppRootKey</param-name>  
    <param-value>myapp.root</param-value>  
</context-param>  
    原文作者:黄言黄语
    原文地址: https://www.jianshu.com/p/942300af5f9c
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞