在Spring Tool Suite中尝试运行tomcat时遇到以下严重异常:
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.util.Log4jConfigListener
java.lang.IllegalStateException: Cannot set web app root system property when WAR file is not expanded
at org.springframework.web.util.WebUtils.setWebAppRootSystemProperty(WebUtils.java:143)
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:4939)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
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)
不要
Log4jConfigListener
在没有扩展的WAR中使用; 我们可能需要更清楚地说明这一点。只有两个好处
Log4jWebConfigurer
:-在Log4J配置文件更改时刷新Log4J配置;-允许使用相对于Web应用程序根目录的日志文件路径。当未扩展WAR时,两者都不适用,因此
Log4jWebConfigurer
在这种情况下使用毫无意义。只需依靠log4j.properties
类路径根目录中的文件中Log4J的默认初始化即可。顺便说一句,您可能已经注意到
Log4jConfigListener
Petclinic和Countrys中已将其注释掉web.xml
,原因是相关的:为了能够部署未扩展的WAR,并且可以在JBoss中轻松地工作(它具有Log4J的特殊用法) 。于尔根
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句