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/

相關文章
相關標籤/搜索