Web app root system property already set to different value:

tomcat启动报如下错误:

java.lang.IllegalStateException:Web app root system property already set to different value: 'webapp.root' = [D:\DevelopmentTools\tomcat-6.0.35-tjh\webapps\amSpring\] instead of [D:\DevelopmentTools\tomcat-6.0.35-tjh\webapps\springmvc\] - Choose unique values for the 'webAppRootKey' context-param in your web.xml files!

错误原因是:

'webapp.root' 这个配置名称已经被使用了,不能再用这个了,提示了Choose unique values for the 'webAppRootKey' context-param in your web.xml files ,也就是说我们可以在web.xml里配置一个唯一的'webAppRootKey' ,这样就不会冲突了。

解决办法:

在web.xml中加上一下配置

	<!-- webAppRootKey Context Config -->
	<context-param>  
	    <param-name>webAppRootKey</param-name>  
	    <param-value>webapp.root</param-value>  
	</context-param> 
如下图:

重启tomcat,错误消失。

附:Log4j的配置:

log4j.rootLogger=INFO, stdout, logfile

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.HTMLLayout
#log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n
log4j.appender.stdout.layout.ConversionPattern=- %m%n

log4j.appender.logfile=org.apache.log4j.RollingFileAppender 
log4j.appender.logfile.File=${webapp.root}/webapp.html
log4j.appender.logfile.MaxFileSize=512KB


# Keep three backup files.
log4j.appender.logfile.MaxBackupIndex=3
# Pattern to output: date priority [category] - message
log4j.appender.logfile.layout=org.apache.log4j.HTMLLayout
log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - %m%n

log4j.logger.com.opensymphony.xwork2=ERROR 

# Control logging for other open source packages
log4j.logger.org.springframework=ERROR
log4j.logger.org.quartz=ERROR
log4j.logger.net.sf.ehcache=ERROR
log4j.logger.net.sf.navigator=ERROR
log4j.logger.org.apache.commons=ERROR
log4j.logger.org.apache.struts=ERROR
log4j.logger.org.hibernate=DEBUG 
# Struts OgnlUtil issues unimportant warnings 
log4j.logger.com.opensymphony.xwork2.util.OgnlUtil=error 
log4j.logger.com.opensymphony.xwork2.ognl.OgnlValueStack=error

在 log4j.properties里就写成${myapp.root},只要这个名称不重复,就不会产生Web app root system property already set to different value的错误了。虽然正式使用时一台服务器部署多个应用程序的情况会比较少,但是还是保险起见吧,也对我们的程序相关的命名标准化吧,把 ${webapp.root}改成${[应用程序].root},这是个好习惯。



你可能感兴趣的:(log4j,MyEclipse)