tomcat 下多个应用时报错

上周作系统上线时,在tomcat的webapps目录下又添加了一个项目mds.war,war正常部署后,经过浏览器不能正常访问,查看tomcat的log,发现以下报错信息:java

16-Apr-2015 08:58:25.937 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.listenerStart 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' = [/data/tomcat/webapps/bocode] instead of [/data/tomcat/webapps/httpjson] - Choose unique values for the 'webAppRootKey' 
 context-param in your web.xml files!
at org.springframework.web.util.WebUtils.setWebAppRootSystemProperty(WebUtils.java:144)
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:4750)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5170)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:724)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:700)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:697)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:919)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1704)
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)

分析上述报错信息:Web app root system property already set to different valueweb

web.xml中webAppRootKeyspring

------------------------------------------------------------------------------------------------apache

一、 web.xml配置 
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>webapp.root</param-value>
</context-param>

"webapp.root"这个字符串能够随便写任何字符串。若是不配置默认值是"webapp.root"。json

 

能够用System.getProperty("webapp.root")来动态获项目的运行路径。浏览器

通常返回结果例如:/datatomcat/webapps/项目名tomcat


二、解决如下报错bash

部署在同一容器中的Web项目,要配置不一样的<param-value>,不能重复,不然报相似下面的错误:app

Web app root system property already set to different value: Web app root system property already set to different value: 'webapp.root' = [/data/tomcat/webapps/bocode] instead of [/data/tomcat/webapps/httpjson] - Choose unique values webapp

for the 'webAppRootKey' context-param in your web.xml files!

意思是“webapp.root”这个key已经指向了项目1,不能够再指向项目2.


解决方法以下:
### app1:
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>app1.root</param-value>
</context-param>
### app2:
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>app2.roo


参考文章: http://elf8848.iteye.com/blog/2008595

       http://yzxqml.iteye.com/blog/1761540

       http://www.thinksaas.cn/group/topic/328055/

相关文章
相关标签/搜索