Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-1222

Initializing Logger during JVM shutdown fails with FATAL error

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.4, 2.5
    • 2.6
    • Core
    • None

    Description

      Trying to stop a web application leads to the following problem:

      [INFO] Stopped ServerConnector@7fad214a{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
      [INFO] Stopped ServerConnector@7793ad58{SSL,[ssl, http/1.1]}{0.0.0.0:8443}
      2015-12-12 19:09:24,604 Thread-1 FATAL Unable to register shutdown hook because JVM is shutting down. java.lang.IllegalStateException: Cannot add new shutdown hook as this is not started. Current state: STOPPED
      	at org.apache.logging.log4j.core.util.DefaultShutdownCallbackRegistry.addShutdownCallback(DefaultShutdownCallbackRegistry.java:113)
      	at org.apache.logging.log4j.core.impl.Log4jContextFactory.addShutdownCallback(Log4jContextFactory.java:271)
      	at org.apache.logging.log4j.core.LoggerContext.setUpShutdownHook(LoggerContext.java:240)
      	at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:201)
      	at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:146)
      	at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:41)
      	at org.apache.logging.log4j.LogManager.getContext(LogManager.java:177)
      	at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:103)
      	at org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:43)
      	at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:42)
      	at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
      	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:284)
      	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:304)
      	at org.apache.wicket.core.util.lang.PropertyResolver.<clinit>(PropertyResolver.java:75)
      	at org.apache.wicket.Application.internalDestroy(Application.java:786)
      	at org.apache.wicket.protocol.http.WebApplication.internalDestroy(WebApplication.java:704)
      	at org.apache.wicket.protocol.http.WicketFilter.destroy(WicketFilter.java:614)
      	at org.eclipse.jetty.servlet.FilterHolder.destroyInstance(FilterHolder.java:172)
      	at org.eclipse.jetty.servlet.FilterHolder.doStop(FilterHolder.java:150)
      	at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:89)
      	at org.eclipse.jetty.util.component.ContainerLifeCycle.stop(ContainerLifeCycle.java:143)
      	at org.eclipse.jetty.util.component.ContainerLifeCycle.doStop(ContainerLifeCycle.java:161)
      	at org.eclipse.jetty.server.handler.AbstractHandler.doStop(AbstractHandler.java:73)
      ....
      

      The problem is at:

      at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:304)
      	at org.apache.wicket.core.util.lang.PropertyResolver.<clinit>(PropertyResolver.java:75)
      

      During shutdown a class (PropertyResolver) is loaded for a first time and its 'private static final Logger' leads to the above problem.

      The problem appears first in 2.4. There is no such issue with 2.3.

      Attachments

        1. log4j2-1222.tgz
          5 kB
          Martin Tzvetanov Grigorov
        2. mini-app.tgz
          20 kB
          Martin Tzvetanov Grigorov

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            rgoers Ralph Goers
            mgrigorov Martin Tzvetanov Grigorov
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment