tomcat下啟動多個應(yīng)用時可能遇到的異常:
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”類加載異常庶弃,其實(shí)這個只是現(xiàn)象,不不是真正引起問題的原因讹堤。
看這個真正的異常原因需要看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應(yīng)用程序根系統(tǒng)屬性已經(jīng)被設(shè)置,'webapp.root' 這個配置名稱已經(jīng)被使用轩娶,提示了Choose unique values for the 'webAppRootKey' context-param in your web.xml files 儿奶,也就是說在web.xml里配置一個唯一的'webAppRootKey' ,這樣就不會發(fā)生沖突鳄抒。
解決辦法
在web.xml
指定webAppRootKey
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>myapp.root</param-value>
</context-param>