您的位置:首页 > 移动开发

java.lang.IllegalStateException: Web app root system property already set to different value: 'webap

2015-12-07 17:07 483 查看

严重: 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' = [D:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\redmanor_b2c_back\] instead of [D:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\redmanor_b2c_front\]
- 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:4973)

at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)

at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)

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重用的问题

当在tomcate中发布多个同根的应用时,容易出现这样异常:

java.lang.IllegalStateException: Web app root system property already set to different value: 'Portal.root' = [C:\jakarta-tomcat-5.0.30\webapps\Portal\] instead of [C:\jakarta-tomcat-5.0.30\webapps\Poral\] - Choose unique values for the 'webAppRootKey' context-param
in your web.xml files!



解决方法 一:

检查发布的多个Web应用的web.xml文件,其中是否定义了相同的webAppRootKey, 如:

### 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>app1.root</param-value> <!-- 第二个应用的根 -->

</context-param>

解决方案二:

webAppRootKey是在java web项目的web.xml配置文件中表示项目的唯一标示,在Eclipse调试Web项目时,项目的路径是一个临时路径,不在真正的路径下,可以通过log4j日志的方式打印出属性值,来看看临时项目路径在哪里,可以用System.getProperty("web.sample.root");如果web.xm 内没有设置webAppRootKey项,是为默认设置,那么webAppRootKey就是缺省的"webapp.root"。

解决办法: 两个web应用中定义了相同的webAppRootKey或者都没有定义,则现在就需要为每个web都定义一个webAppRootKey。

### 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.root</param-value>

</context-param>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: