Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SEVERE: Exception org.springframework.web.util.Log4jConfigListener

Getting the below severe exception when attempting to run tomcat in Spring Tool Suite:

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)
like image 936
Sean Keane Avatar asked Jun 20 '14 22:06

Sean Keane


2 Answers

Don't use Log4jConfigListener within a WAR that is not expanded; we probably need to make that even clearer.

There's only two benefits that Log4jWebConfigurer gives you: - refreshes Log4J configuration when the Log4J config file changes; - allows to use log file paths relative to the web applicaiton root.

Both are not applicable when the WAR is not expanded, so there's no point in using Log4jWebConfigurer in such a scenario. Simply rely on Log4J's default initialization from a log4j.properties file in the root of the classpath.

BTW, you might have noticed that Log4jConfigListener is commented-out in Petclinic's and Countries' web.xml, for a related reason: To be able to deploy WARs that are not expanded, and to work without hassle in JBoss (which has its own special usage of Log4J).

Juergen

like image 153
Artem Bilan Avatar answered Oct 22 '22 22:10

Artem Bilan


Log4jConfigListener only works if the WAR file is exploded. Read this article: http://community.jaspersoft.com/wiki/illegalstateexception-while-deploying-war-file-weblogic

like image 22
Green Lei Avatar answered Oct 22 '22 21:10

Green Lei