由于懒惰想copy一份工程来做测试用因此当AVerPortal 和AverPortalTest 都在tomcat的编译项目的时候会出现错误
2010-5-14 9:45:40 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' = [F:\JDKandTOMCAT\TOMCAT\Tomcat 6.0\webapps\AVerPortal\] instead of [F:\JDKandTOMCAT\TOMCAT\Tomcat 6.0\webapps\AVerPortalTest\] - Choose unique values for the 'webAppRootKey' context-param in your web.xml files!
原因是当在web.xml中没指定
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>AVerPortalTest</param-value>
</context-param>
的时候按照默认的
做法1
在tomcatserver启动项目目录删除AVerPortal 和AverPortalTest 其中一个
做法2
在web.XML中添加webAppRootKey指定好
以下是转帖
近日,因为懒惰,直接从原有项目切出一个分块成了一个项目,然后同时发布启动,出现以下异常
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:\tomcat-5.0.19\webapps\tzbms\] instead of [D:\tomcat-5.0.19\webapps\its\] - Choose unique values for the 'webAppRootKey' context-param in your web.xml files!
at org.springframework.web.util.WebUtils.setWebAppRootSystemProperty(WebUtils.java:99)
at org.springframework.web.util.Log4jWebConfigurer.initLogging(Log4jWebConfigurer.java:116)
at org.springframework.web.util.Log4jConfigListener.contextInitialized(Log4jConfigListener.java:51)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3773)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4270)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:866)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:850)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:638)
at org.apache.catalina.core.StandardHostDeployer.install(StandardHostDeployer.java:320)
at org.apache.catalina.core.StandardHost.install(StandardHost.java:875)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:657)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:476)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1008)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:394)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:166)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1134)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:832)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1126)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:521)
at org.apache.catalina.core.StandardService.start(StandardService.java:519)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:2345)
at org.apache.catalina.startup.Catalina.start(Catalina.java:594)
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:324)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:297)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:398)
看看异常,还是挺简单的,应该是两个项目的设置重复了,导致出错,但我发现web.xml里并没有配置webAppRootKey项,然后查阅网上资料,参考
hwctl的专栏http://blog.csdn.net/hwctl/archive/2007/07/31/1719597.aspx
,原来是因为如果没有web.xm 内没有设置webAppRootKey项,是为默认设置
public static void setWebAppRootSystemProperty(ServletContext servletContext) throws IllegalStateException {
String param = servletContext.getInitParameter(WEB_APP_ROOT_KEY_PARAM);
String key = (param != null ? param : DEFAULT_WEB_APP_ROOT_KEY);
String oldValue = System .getProperty(key);
if (oldValue != null ) {
throw new IllegalStateException ("WARNING: Web app root system property already set: " + key + " = " +
oldValue + " - Choose unique webAppRootKey values in your web.xml files!" );
}
String root = servletContext.getRealPath("/" );
if (root == null ) {
throw new IllegalStateException ("Cannot set web app root system property when WAR file is not
expanded");
}
System .setProperty(key, root);
servletContext.log("Set web app root system property: " + key + " = " + root);
}
从代码看出,该方法其实就是把该web application的根目录的绝对文件路径作为属性保存在 System的属性列表中。该属性的名字,由web.xml文件中的名为"webAppRootKey"的参数值指出。如果不在web.xml中定义 webAppRootKey参数,那么属性名就是缺省的"webapp.root".在我们的petclinic项目中已经定义了 webAppRootKey参数,其值为"petclinic.root",因此,属性的名字就是"petclinic.root".
最后将webAppRootKey项配置好,错误解决。
分享到:
相关推荐
WebApp.cspro
基于easyUI为环境的前端简单环境搭建包(easyUI+jQuery+jsp)
用python搭建自己的一个小的服务器,并运行自己的web应用。
angular1.x 移动端开发webapp.zip
赠送jar包:jetty-webapp-9.3.19.v20170502.jar; 赠送原API文档:jetty-webapp-9.3.19.v20170502-javadoc.jar; 赠送源代码:jetty-webapp-9.3.19.v20170502-sources.jar; 赠送Maven依赖信息文件:jetty-webapp-...
基于Html5的webapp.pdf
springboot跨服务器文件上传,前端界面
从0到1实战移动WebApp.txt
001_WebApp.pdf 章节概述 • 网站部署规划 部署网站 配置网站 监视网站 流量管理器 创建和配置网站 演示 1 :中国版 Windows Azure 创建新网站 使用 FTP 部署网站 使用 Web 部署来部署网站 演示 2 :...
Nationality_n_Gender Predictor_ML-WebApp.zip
skywalking 8.7 安装包,包括agent,skywalking-webapp.jar
现在很多企业都要做PDA开发,但又不想使用Android 开发,因为Android原生开发...在开发过程中,遇到了很多问题,为了帮助同病相怜的XX,将初始程序上传,希望对相关人员有所帮助。此程序主要实现了相机扫描,红外扫描。
Ajax-beat-webapp.zip,一个用于beat machine api的简单webapp。,ajax代表异步javascript和xml。它是多种web技术的集合,包括html、css、json、xml和javascript。它用于创建动态网页,其中网页的小部分在不重新加载...
webapp.zip
webapp.sb3
comet 很好的一个实例 var ajax = new Ajax.Request(WebApp._url_, { method: 'get', parameters: { 'timestamp' : WebApp._timestamp_ }, onSuccess: function(transport) { var response = ...
Angular-generator-fountain-webapp.zip,Yeoman“Fountain”生成器启动未维护的webapp,Angularjs于2016年发布,是Angularjs的重写版。它专注于良好的移动开发、模块化和改进的依赖注入。angular的设计目的是全面解决...