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

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

2017-08-28 15:58 549 查看
本来在tomcat的webapps中ROOT目录丢了一个默认的java项目,独立启动tomcat一切运行正常,后又因为业务需要在webapps下丢了一个war包,结果启动的时候catalina.out中没有显示什么显眼的错误日志,开始没在意,任务项目已经部署成功,就分别取访问这两个项目,测试结果发现war包的项目访问是正常的,而ROOT目录下的项目算是崩溃了,

然后仔细查看日志,发现具体错误需要去看localhost.log。果然发现错误信息,如下:

**java.lang.IllegalStateException: Web app root system property already set to different value: ‘webapp.root’ = [/tomcat/webapps/project/] instead of [/tomcat/webapps/ROOT/] - Choose unique values for the ‘webAppRootKey’ context-param in your web.xml files!

at org.springframework.web.util.WebUtils.setWebAppRootSystemProperty(WebUtils.java:161)

at org.springframework.web.util.Log4jWebConfigurer.initLogging(Log4jWebConfigurer.java:117)

at org.springframework.web.util.Log4jConfigListener.contextInitialized(Log4jConfigListener.java:46)

at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5118)

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

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

at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899)

at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)

at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)

at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1260)

at org.apache.catalina.startup.HostConfigDeployDirectory.run(HostConfig.java:2002)atjava.util.concurrent.ExecutorsRunnableAdapter.call(Executors.java:511)

at java.util.concurrent.FutureTask.run(FutureTask.java:266)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

at java.lang.Thread.run(Thread.java:745)**

大概的错误意思是web.xml没有明确地声明,导致部署顺序先部署的项目成功了,后部署的项目发现tomcat已经存在了同样声明的项目。

所以我们需要在web.xml中对各自项目进行声明,如果不声明,那么默认的webapp.root就会变成先部署的项目路径。

为了图方便,默认的ROOT下的项目就继续保持现状,修改project项目的web.xml,对它重新进行声明。加入如下信息:

<context-param>
<param-name>webAppRootKey</param-name>
<param-value>haha.root</param-value>
</context-param>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  java exception
相关文章推荐