博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Web app root system property already set to different value 的解决办法
阅读量:4052 次
发布时间:2019-05-25

本文共 2997 字,大约阅读时间需要 9 分钟。

 

Hi all, 

when deploying two applications build from the riot skeleton within   

the same Tomcat servlet container, you get an 

IllegalStateException: Web app root system property already set to   

different value: 'webapp.root' = [/Users/joe/ 
Workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/webapps/ 
webapp-A/] instead of [/Users/joe/Workspace/.metadata/.plugins/ 
org.eclipse.wst.server.core/tmp0/webapps/webapp-B/] - Choose unique   
values for the 'webAppRootKey' context-param in your web.xml files! 

I will try to explain where this comes from and how to circumvent it,   

but first the quick fix for the impatient reader: Place a context   
parameter named 'webAppRootKey' in every project's web.xml and assign   
value to it, that is unique for every of your projects like the   
project name itself. 

The webAppRootKey context parameter is introduced by Spring. Along   

with the WebAppRootListener it allows exposing the web applications   
root directory as a system property. The value of the context   
parameter 'webAppRootKey' names the system property to use. If the   
context parameter 'webAppRootKey' is not set in the application's   
web.xml, Spring chooses the default value 'app.root'. While some   
servlet containers like Resin do isolate each web application's   
system properties, others like Tomcat do not. And that's what the   
former mentioned IllegalStateException is telling us:  The system   
property
 'app.rootalready contains the root directory of the first   
web application when Spring tries to assign the root directoty of the   
second application to it. 

Ok, that's the background information. A deeper look into the web.xml   

tells us, that there ist no WebAppRootListener configured. Why does   
this initialisation take place anyway? The stack trace from the   
exception reveals the culprit: The Log4jConfigListener also tries to   
set the webAppRootKey, because this is an interesting mechanism for   
the Spring/Log4j integration. It allows log and config file locations   
relative to the web applications root directory. The   
Log4jConfigListener supports three init parameters at the servlet   
context level: 'log4jConifgLocation', 'log4jRefreshInterval' and   
'log4jExposeWebAppRoot'. See JavaDocs for more informations. 

But, none of these parameters are set in the riot project skeleton's   

web.xml and none of the Log4jWebConfigureres features are used by the   
riot project skeleton. As long as you do stay with default log4j   
setup, the Log4jConfigListener is superflous. 

At the end there are three possible solutions for the initial problem: 

(1) Provide any of your applications with a unique 'webAppRootKey'. 

(2) Set the servlet context parameter 'log4jExposeWebAppRoot' to   
'false'. This eliminates the use of log file locations relative to   
the web application's root directory but still allows a log4j config   
location outside the classpath. 
(3) Remove the 'Log4jConfigListener' from your application's web.xml. 

What do you think is the best solution and should be incorporated   

into the riot skeleton project?

转载地址:http://tltci.baihongyu.com/

你可能感兴趣的文章
分布式缓存负载均衡负载均衡的缓存处理:虚拟节点对一致性hash的改进
查看>>
分布式存储系统设计(1)—— 系统架构
查看>>
MySQL数据库的高可用方案总结
查看>>
常用排序算法总结(一) 比较算法总结
查看>>
SSH原理与运用
查看>>
SIGN UP BEC2
查看>>
S3C2440中对LED驱动电路的理解
查看>>
《天亮了》韩红
查看>>
Windows CE下USB摄像头驱动开发(以OV511为例,附带全部源代码以及讲解) [转]
查看>>
出现( linker command failed with exit code 1)错误总结
查看>>
iOS开发中一些常见的并行处理
查看>>
iOS获取手机的Mac地址
查看>>
ios7.1发布企业证书测试包的问题
查看>>
如何自定义iOS中的控件
查看>>
iOS 开发百问
查看>>
Mac环境下svn的使用
查看>>
github简单使用教程
查看>>
如何高效利用GitHub
查看>>
环境分支-git版本管理
查看>>
uni-app 全局变量
查看>>