【问题标题】:SEVERE: Exception org.springframework.web.util.Log4jConfigListener严重:异常 org.springframework.web.util.Log4jConfigListener
【发布时间】:2014-08-11 17:59:36
【问题描述】:

尝试在 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)

【问题讨论】:

    标签: java spring spring-mvc


    【解决方案1】:

    不要在未扩展的 WAR 中使用Log4jConfigListener;我们可能 需要更清楚地说明这一点。

    Log4jWebConfigurer 给您带来的好处只有两个: - 当 Log4J 配置文件更改时刷新 Log4J 配置; - 允许使用相对于 Web 应用程序根目录的日志文件路径。

    当WAR没有展开时,两者都不适用,所以没有意义 在这种情况下使用Log4jWebConfigurer。只需依赖 Log4J 的默认值 从类路径根目录中的 log4j.properties 文件初始化。

    顺便说一句,您可能已经注意到 Log4jConfigListener 在 Petclinic 和国家的web.xml,出于相关原因:能够部署 未扩展的 WAR,并且可以在 JBoss 中轻松工作(它有 自己对 Log4J 的特殊用法)。

    于尔根

    【讨论】:

      【解决方案2】:

      Log4jConfigListener 仅在 WAR 文件被分解时才有效。阅读这篇文章:http://community.jaspersoft.com/wiki/illegalstateexception-while-deploying-war-file-weblogic

      【讨论】:

        猜你喜欢
        • 2019-11-16
        • 1970-01-01
        • 2014-09-16
        • 2012-09-04
        • 1970-01-01
        • 2021-04-08
        • 2013-04-29
        • 2016-02-17
        • 2015-09-03
        相关资源
        最近更新 更多