title: Spring Boot and Logback: Exception thrown from ApplicationListener handling ContextClosedEvent
body: <p>I have recently updated my Spring Boot version from 1.4.0 to 1.4.1 and started to get this error while running my app from IntelliJ: </p>
  
  <pre><code>15:26:09.700  INFO [Thread-2] AnnotationConfigApplicationContext     - Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@2898ac89: startup date [Fri Nov 25 15:26:04 EET 2016]; root of context hierarchy
  15:26:09.701  WARN [Thread-2] AnnotationConfigApplicationContext     - Exception thrown from ApplicationListener handling ContextClosedEvent
  java.lang.NoSuchMethodError: ch.qos.logback.classic.LoggerContext.removeObject(Ljava/lang/String;)V
      at org.springframework.boot.logging.logback.LogbackLoggingSystem.markAsUninitialized(LogbackLoggingSystem.java:265) ~[spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
      at org.springframework.boot.logging.logback.LogbackLoggingSystem.cleanUp(LogbackLoggingSystem.java:196) ~[spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
      at org.springframework.boot.logging.LoggingApplicationListener.onContextClosedEvent(LoggingApplicationListener.java:248) ~[spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
      at org.springframework.boot.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:216) ~[spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
      at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:166) ~[spring-context-4.3.3.RELEASE.jar:4.3.3.RELEASE]
      at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:138) ~[spring-context-4.3.3.RELEASE.jar:4.3.3.RELEASE]
      at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:382) ~[spring-context-4.3.3.RELEASE.jar:4.3.3.RELEASE]
      at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:336) ~[spring-context-4.3.3.RELEASE.jar:4.3.3.RELEASE]
      at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:989) ~[spring-context-4.3.3.RELEASE.jar:4.3.3.RELEASE]
      at org.springframework.context.support.AbstractApplicationContext$2.run(AbstractApplicationContext.java:923) [spring-context-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  </code></pre>
  
  <p>Here is my pom:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
           xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;groupId&gt;repgen&lt;/groupId&gt;
      &lt;artifactId&gt;RepGen&lt;/artifactId&gt;
      &lt;version&gt;1.0&lt;/version&gt;
  
      &lt;name&gt;RepGen&lt;/name&gt;
      &lt;packaging&gt;jar&lt;/packaging&gt;
  
      &lt;parent&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
          &lt;version&gt;1.4.1.RELEASE&lt;/version&gt;
      &lt;/parent&gt;
  
      &lt;properties&gt;
          &lt;!-- Generic properties --&gt;
          &lt;java.version&gt;1.7&lt;/java.version&gt;
          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
          &lt;project.reporting.outputEncoding&gt;UTF-8&lt;/project.reporting.outputEncoding&gt;
          &lt;hibernate.version&gt;5.2.2.Final&lt;/hibernate.version&gt;
          &lt;start-class&gt;repgen.Application&lt;/start-class&gt;
          &lt;!-- Test --&gt;
          &lt;assertj.version&gt;2.2.0&lt;/assertj.version&gt;
      &lt;/properties&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
              &lt;version&gt;1.4.1.RELEASE&lt;/version&gt;
              &lt;exclusions&gt;
                  &lt;exclusion&gt;
                      &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
                      &lt;artifactId&gt;hibernate-entitymanager&lt;/artifactId&gt;
                  &lt;/exclusion&gt;
              &lt;/exclusions&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-jdbc&lt;/artifactId&gt;
              &lt;version&gt;1.4.1.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-actuator&lt;/artifactId&gt;
              &lt;version&gt;1.4.1.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-mail&lt;/artifactId&gt;
              &lt;version&gt;1.4.1.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
              &lt;version&gt;1.4.1.RELEASE&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-configuration-processor&lt;/artifactId&gt;
              &lt;version&gt;1.4.1.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;!-- HIBERNATE --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
              &lt;artifactId&gt;hibernate-entitymanager&lt;/artifactId&gt;
              &lt;!--&lt;version&gt;5.2.2.FINAL&lt;/version&gt;--&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
              &lt;artifactId&gt;hibernate-validator&lt;/artifactId&gt;
              &lt;version&gt;5.2.4.Final&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;!-- Logback --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;ch.qos.logback&lt;/groupId&gt;
              &lt;artifactId&gt;logback-core&lt;/artifactId&gt;
              &lt;version&gt;1.1.2&lt;/version&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.2&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;!-- Log4j --&gt;
          &lt;!--&lt;dependency&gt;--&gt;
              &lt;!--&lt;groupId&gt;log4j&lt;/groupId&gt;--&gt;
              &lt;!--&lt;artifactId&gt;log4j&lt;/artifactId&gt;--&gt;
              &lt;!--&lt;version&gt;1.2.16&lt;/version&gt;--&gt;
          &lt;!--&lt;/dependency&gt;--&gt;
          &lt;!-- JODA-TIME --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;joda-time&lt;/groupId&gt;
              &lt;artifactId&gt;joda-time&lt;/artifactId&gt;
              &lt;version&gt;2.9.4&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;!-- APACHE COMMONS for List Utils --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.commons&lt;/groupId&gt;
              &lt;artifactId&gt;commons-collections4&lt;/artifactId&gt;
              &lt;version&gt;4.1&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;!-- SAXON XSLT Processor --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;net.sf.saxon&lt;/groupId&gt;
              &lt;artifactId&gt;Saxon-HE&lt;/artifactId&gt;
              &lt;version&gt;9.7.0-8&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;!-- APACHE FOP for xsl-fo object formatting --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.xmlgraphics&lt;/groupId&gt;
              &lt;artifactId&gt;fop&lt;/artifactId&gt;
              &lt;version&gt;2.1&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;!-- APACHE POI for office documents --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.poi&lt;/groupId&gt;
              &lt;artifactId&gt;poi-ooxml&lt;/artifactId&gt;
              &lt;version&gt;3.13&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.poi&lt;/groupId&gt;
              &lt;artifactId&gt;ooxml-schemas&lt;/artifactId&gt;
              &lt;version&gt;1.3&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;!-- Databases: Oracle. This needs to be manually imported into local Maven repo. --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.oracle&lt;/groupId&gt;
              &lt;artifactId&gt;ojdbc6&lt;/artifactId&gt;
              &lt;version&gt;11.2.0.4&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;!-- JAVA Mail --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.mail&lt;/groupId&gt;
              &lt;artifactId&gt;javax.mail-api&lt;/artifactId&gt;
              &lt;version&gt;1.5.5&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;!-- ZIP file related --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;net.lingala.zip4j&lt;/groupId&gt;
              &lt;artifactId&gt;zip4j&lt;/artifactId&gt;
              &lt;version&gt;1.3.1&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;!-- Test Artifacts --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;junit&lt;/groupId&gt;
              &lt;artifactId&gt;junit&lt;/artifactId&gt;
              &lt;version&gt;4.12&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.assertj&lt;/groupId&gt;
              &lt;artifactId&gt;assertj-core&lt;/artifactId&gt;
              &lt;version&gt;2.2.0&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.mockito&lt;/groupId&gt;
              &lt;artifactId&gt;mockito-core&lt;/artifactId&gt;
              &lt;version&gt;1.10.19&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.commons&lt;/groupId&gt;
              &lt;artifactId&gt;commons-lang3&lt;/artifactId&gt;
              &lt;version&gt;3.4&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.dbunit&lt;/groupId&gt;
              &lt;artifactId&gt;dbunit&lt;/artifactId&gt;
              &lt;version&gt;2.5.1&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
              &lt;exclusions&gt;
                  &lt;exclusion&gt;
                      &lt;artifactId&gt;junit&lt;/artifactId&gt;
                      &lt;groupId&gt;junit&lt;/groupId&gt;
                  &lt;/exclusion&gt;
              &lt;/exclusions&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.github.springtestdbunit&lt;/groupId&gt;
              &lt;artifactId&gt;spring-test-dbunit&lt;/artifactId&gt;
              &lt;version&gt;1.2.1&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
      &lt;build&gt;
          &lt;testSourceDirectory&gt;test&lt;/testSourceDirectory&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
                  &lt;version&gt;1.4.0.RELEASE&lt;/version&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
      &lt;repositories&gt;
          &lt;repository&gt;
              &lt;id&gt;spring-releases&lt;/id&gt;
              &lt;name&gt;Spring Releases&lt;/name&gt;
              &lt;url&gt;https://repo.spring.io/libs-release&lt;/url&gt;
          &lt;/repository&gt;
          &lt;repository&gt;
              &lt;id&gt;org.jboss.repository.releases&lt;/id&gt;
              &lt;name&gt;JBoss Maven Release Repository&lt;/name&gt;
              &lt;url&gt;https://repository.jboss.org/nexus/content/repositories/releases&lt;/url&gt;
          &lt;/repository&gt;
      &lt;/repositories&gt;
      &lt;pluginRepositories&gt;
          &lt;pluginRepository&gt;
              &lt;id&gt;spring-releases&lt;/id&gt;
              &lt;name&gt;Spring Releases&lt;/name&gt;
              &lt;url&gt;https://repo.spring.io/libs-release&lt;/url&gt;
          &lt;/pluginRepository&gt;
      &lt;/pluginRepositories&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>The application works fine, but this exception is thrown at the end of the operation. I have tried to find anything related, but those solutions do not help my case...</p>