码迷,mamicode.com
首页 > 其他好文 > 详细

tomcat 下多个应用时报错

时间:2015-04-21 10:00:00      阅读:187      评论:0      收藏:0      [点我收藏+]

标签:tomcat报错   tomcat多应用   

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

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 value

web.xml中webAppRootKey

------------------------------------------------------------------------------------------------

1、 web.xml配置 

<context-param>

<param-name>webAppRootKey</param-name>

<param-value>webapp.root</param-value>

</context-param>

"webapp.root"这个字符串可以随便写任何字符串。如果不配置默认值是"webapp.root"。

 

可以用System.getProperty("webapp.root")来动态获项目的运行路径。

一般返回结果例如:/datatomcat/webapps/项目名


2、解决以下报错

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

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 

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/


本文出自 “nagios故障” 博客,请务必保留此出处http://5250070.blog.51cto.com/5240070/1636323

tomcat 下多个应用时报错

标签:tomcat报错   tomcat多应用   

原文地址:http://5250070.blog.51cto.com/5240070/1636323

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!