title: How to configure Log4j for Spring on JBoss
body: <p>I am trying to deploy spring mvc + tiles demo project on my JBoss 5.1.0GA server. I run into this issue with Log4J:</p>
  
  <pre><code>    02:35:49,443 ERROR [StandardContext] Error listenerStart
  02:35:49,443 ERROR [StandardContext] Context [/travel] startup failed due to previous errors
  02:35:49,443 INFO  [[/travel]] Closing Spring root WebApplicationContext
  [Loaded org.springframework.web.context.ContextCleanupListener from jar:file:/opt/jboss-5.1.0.GA/server/default/deploy/travel.war!/WEB-INF/lib/spring-web-3.0.5.RELEASE.jar]
  02:35:49,444 ERROR [[/travel]] Exception sending context destroyed event to listener instance of class org.springframework.web.context.ContextLoaderListener
  java.lang.NoClassDefFoundError: Could not initialize class org.apache.log4j.LogManager
          at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:73)
          at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:249)
          at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:155)
          at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:131)
          at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:645)
          at org.springframework.web.context.ContextCleanupListener.&lt;clinit&gt;(ContextCleanupListener.java:43)
          at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:80)
          at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:3949)
          at org.apache.catalina.core.StandardContext.stop(StandardContext.java:4615)
          at org.apache.catalina.core.StandardContext.start(StandardContext.java:4437)
          at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeployInternal(TomcatDeployment.java:310)
          at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeploy(TomcatDeployment.java:142)
          at org.jboss.web.deployers.AbstractWarDeployment.start(AbstractWarDeployment.java:461)
          at org.jboss.web.deployers.WebModule.startModule(WebModule.java:118)
          at org.jboss.web.deployers.WebModule.start(WebModule.java:97)
          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:597)
          at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157)
          at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96)
          at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
          at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
          at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:668)
          at org.jboss.system.microcontainer.ServiceProxy.invoke(ServiceProxy.java:206)
          at $Proxy38.start(Unknown Source)
          at org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:42)
          at org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:37)
          at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)
  </code></pre>
  
  <p>And here is my web.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&gt;
  
      &lt;!-- The definition of the Root Spring Container shared by all Servlets and Filters --&gt;
      &lt;context-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;classpath:/META-INF/spring/root-context.xml&lt;/param-value&gt;
      &lt;/context-param&gt;
  
      &lt;!-- Creates the Spring Container shared by all Servlets and Filters --&gt;
      &lt;listener&gt;
          &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
      &lt;/listener&gt;
  
      &lt;!-- Enables use of HTTP methods PUT and DELETE --&gt;
      &lt;filter&gt;
          &lt;filter-name&gt;httpMethodFilter&lt;/filter-name&gt;
          &lt;filter-class&gt;org.springframework.web.filter.HiddenHttpMethodFilter&lt;/filter-class&gt;
      &lt;/filter&gt;
  
      &lt;filter-mapping&gt;
          &lt;filter-name&gt;httpMethodFilter&lt;/filter-name&gt;
          &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
      &lt;/filter-mapping&gt;
  
      &lt;!-- Handles all requests into the application --&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;travel&lt;/servlet-name&gt;
          &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
              &lt;param-value&gt;classpath:/META-INF/spring/travel/servlet-context.xml&lt;/param-value&gt;
          &lt;/init-param&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
  
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;travel&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  
  &lt;/web-app&gt;
  </code></pre>
  
  <p>I am thinking that cause of this might be double log4j.jar on classpath but how do I check?</p>