java.lang.IllegalStateException: Web app root system property already set to different value...
2017-03-27 13:35
721 查看
java.lang.IllegalStateException: Web app root system property already set to different value: ‘webapp.root’ = [xxx]
Ref:http://stackoverflow.com/questions/5014651/webapproot-in-springErrors:
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' = [D:\N_Eclipse_32bit\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\GYMOBM\] instead of [D:\N_Eclipse_32bit\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\HNMOBM\] - 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:4206) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057) at org.apache.catalina.core.StandardHost.start(StandardHost.java:840) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463) at org.apache.catalina.core.StandardService.start(StandardService.java:525) at org.apache.catalina.core.StandardServer.start(StandardServer.java:754) at org.apache.catalina.startup.Catalina.start(Catalina.java:595) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) Mar 27, 2017 1:22:28 PM org.apache.catalina.core.ApplicationContext log INFO: Initializing Spring root WebApplicationContext
Solution:
The webAppRootKey is a context parameter that Spring uses in a couple of places. In this case, it’s being used by the Log4jWebConfigurer. It exposes the webapp root as a system property that can be used in log4j configuration files, something like this:log4j.appender.testfile.File=${webapp.root}/WEB-INF/testlog.log
You would use this if you, for some reason, wanted to locate your logs relative to your webapp root.
The problem that you’re running into is that some containers (notably Tomcat) don’t maintain a per-webapp mapping of system properties. When you don’t specify a webAppRootKey, Spring defaults it to webapp.root. Since you’re running two apps in the same container, the second app you’re trying to start up sees that the webAppRootKey is already set (via the default), and throws an error. Otherwise, the webAppRootKey would be set incorrectly, and you could end up with logs from one webapp in another webapp.
You can specify a different webAppRootKey using context parameters in your web.xml like so:
<context-param> <param-name>webAppRootKey</param-name> <param-value>webapp.root.one</param-value> </context-param>
And
log4j.appender.testfile.File=${webapp.root.one}/WEB-INF/testlog.log
in your log4j. This should take care of the conflict.
by Mike Sun; 2017-03-27
相关文章推荐
- java.lang.IllegalStateException: Web app root system property already set to different value
- java.lang.IllegalStateException:Web app root system property already set to different value 错误原因及解决 Log4j
- java.lang.IllegalStateException: Web app root system property already set to different value .
- java.lang.IllegalStateException: Web app root system property already set to different value .
- java.lang.IllegalStateException: Web app root system property already set to different value
- java.lang.IllegalStateException: Web app root system property already set to different value: 'webap
- java.lang.IllegalStateException: Web app root system property already set to different value: 'webap
- java.lang.IllegalStateException: Web app root system property already set to different value
- java.lang.IllegalStateException: Web app root system property already set to different value
- java.lang.IllegalStateException: Web app root system property already set to different value .
- java.lang.IllegalStateException:Web app root system property already set to different value 错误原因及解决
- java.lang.IllegalStateException: Web app root system property already set to different value
- java.lang.IllegalStateException: Web app root system property already set to different value: 'webap
- java.lang.IllegalStateException: Web app root system property already set to different value:
- java.lang.IllegalStateException: Web app root system property already set to different value
- java.lang.IllegalStateException: Web app root system property already set to different value
- java.lang.IllegalStateException: Web app root system property already set to different value
- Web app root system property already set to different value
- Debug:tomcat:Web app root system property already set to different value:
- tomcatec出错-Web app root system property already set to different value