title: slf4j - logback NullPointer in Spring MVC tests
body: <p>I am running some unit tests and I was to use SLF4J and logback.</p>
  
  <p>Here is the relevant pom.xml</p>
  
  <pre><code>     &lt;dependency&gt;
      &lt;groupId&gt;org.springframework&lt;/groupId&gt;
      &lt;artifactId&gt;spring-test&lt;/artifactId&gt;
      &lt;version&gt;4.2.6-RELEASE&lt;/version&gt;
      &lt;exclusions&gt;
        &lt;exclusion&gt;
          &lt;groupId&gt;commons-logging&lt;/groupId&gt;
          &lt;artifactId&gt;commons-logging&lt;/artifactId&gt;
        &lt;/exclusion&gt;
      &lt;/exclusions&gt;
      &lt;scope&gt;test&lt;/scope&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;ch.qos.logback&lt;/groupId&gt;
      &lt;artifactId&gt;logback-classic&lt;/artifactId&gt;
      &lt;version&gt;1.1.7&lt;/version&gt;
  &lt;/dependency&gt;   
  &lt;dependency&gt;
      &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
      &lt;artifactId&gt;jcl-over-slf4j&lt;/artifactId&gt;
      &lt;version&gt;1.7.21&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>And here is the log and stacktrace:</p>
  
  <pre><code>20:29:16,293 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback-test.xml] at [file:/code/web/target/test-classes/logback-test.xml]
  20:29:16,387 |-ERROR in ch.qos.logback.core.joran.event.SaxEventRecorder@7a1ebcd8 - Unexpected exception while parsing XML document. java.lang.NullPointerException
  at java.lang.NullPointerException
  at  at org.xml.sax.helpers.LocatorImpl.&lt;init&gt;(LocatorImpl.java:103)
  at  at ch.qos.logback.core.joran.event.SaxEvent.&lt;init&gt;(SaxEvent.java:31)
  at  at ch.qos.logback.core.joran.event.StartEvent.&lt;init&gt;(StartEvent.java:27)
  at  at ch.qos.logback.core.joran.event.SaxEventRecorder.startElement(SaxEventRecorder.java:106)
  at  at org.allcolor.xml.parser.CShaniSaxParser.parseStartTag(CShaniSaxParser.java:1393)
  at  at org.allcolor.xml.parser.CXmlParser.parseSTARTTag(CXmlParser.java:1405)
  at  at org.allcolor.xml.parser.CXmlParser.parse(CXmlParser.java:682)
  at  at org.allcolor.xml.parser.CShaniSaxParser.parse(CShaniSaxParser.java:767)
  at  at javax.xml.parsers.SAXParser.parse(SAXParser.java:392)
  at  at ch.qos.logback.core.joran.event.SaxEventRecorder.recordEvents(SaxEventRecorder.java:59)
  at  at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:141)
  at  at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:103)
  at  at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:53)
  at  at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:75)
  at  at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:150)
  at  at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:84)
  at  at org.slf4j.impl.StaticLoggerBinder.&lt;clinit&gt;(StaticLoggerBinder.java:55)
  at  at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150)
  at  at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124)
  at  at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:412)
  at  at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:357)
  at  at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:155)
  at  at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:132)
  at  at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:685)
  at  at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.&lt;clinit&gt;(SpringJUnit4ClassRunner.java:91)
  at  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  at  at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
  at  at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
  at  at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
  at  at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
  </code></pre>
  
  <p>And the logback-test.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;configuration&gt;
      &lt;appender name="consoleAppender" class="ch.qos.logback.core.ConsoleAppender"&gt;
          &lt;encoder&gt;
              &lt;Pattern&gt;.%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg %n
              &lt;/Pattern&gt;
          &lt;/encoder&gt;
          &lt;filter class="ch.qos.logback.classic.filter.ThresholdFilter"&gt;
              &lt;level&gt;TRACE&lt;/level&gt;
          &lt;/filter&gt;
      &lt;/appender&gt;
      &lt;root&gt;
          &lt;level value="INFO" /&gt;
          &lt;appender-ref ref="consoleAppender" /&gt;
      &lt;/root&gt; 
      &lt;logger name="com.me.ControllerTester" level="debug" additivity="false"&gt;
          &lt;appender-ref ref="consoleAppender" /&gt;
      &lt;/logger&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Now I have checked the dependency tree, and I have nothing conflicting.  I have tried messing with the SAX parser versions.</p>
  
  <p>The XML looks fine to me.  I must be conflicted somehow...</p>
  
  <p>Any Ideas?</p>