java.lang.IllegalStateException: Context has been already given a name

QOS.ch JIRA | Joern Huxhorn | 4 years ago
  1. 0

    With a default logback.xml containing this <?xml version="1.0" encoding="UTF-8"?> <configuration> <contextName>Foo</contextName> [..] </configuration> reloading the Logback configuration by means of private static void initLogbackConfig(URL configUrl) { ILoggerFactory loggerFactory = LoggerFactory.getILoggerFactory(); if(loggerFactory instanceof LoggerContext) { LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory(); // reset previous configuration initially loaded from logback.xml loggerContext.reset(); JoranConfigurator configurator = new JoranConfigurator(); configurator.setContext(loggerContext); try { configurator.doConfigure(configUrl); StatusPrinter.print(loggerContext); } catch(JoranException ex) { StatusPrinter.print(loggerContext); } } } with a file containing <?xml version="1.0" encoding="UTF-8"?> <configuration> <contextName>Foobar</contextName> [..] </configuration> produces the following error: 12:21:28,919 |-ERROR in ch.qos.logback.classic.joran.action.ContextNameAction - Failed to rename context [Foo] as [Foobar] java.lang.IllegalStateException: Context has been already given a name at java.lang.IllegalStateException: Context has been already given a name at at ch.qos.logback.core.ContextBase.setName(ContextBase.java:128) at at ch.qos.logback.classic.LoggerContext.setName(LoggerContext.java:107) at at ch.qos.logback.classic.joran.action.ContextNameAction.body(ContextNameAction.java:31) at at ch.qos.logback.core.joran.spi.Interpreter.callBodyAction(Interpreter.java:296) at at ch.qos.logback.core.joran.spi.Interpreter.characters(Interpreter.java:176) at at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:57) at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:157) at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:143) at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:106) at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:56) Is this expected behavior? After all, loggerContext.reset() has been called and I'd assume that this would also reset the contextName. Feels like a bug.

    QOS.ch JIRA | 4 years ago | Joern Huxhorn
    java.lang.IllegalStateException: Context has been already given a name
  2. 0

    With a default logback.xml containing this <?xml version="1.0" encoding="UTF-8"?> <configuration> <contextName>Foo</contextName> [..] </configuration> reloading the Logback configuration by means of private static void initLogbackConfig(URL configUrl) { ILoggerFactory loggerFactory = LoggerFactory.getILoggerFactory(); if(loggerFactory instanceof LoggerContext) { LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory(); // reset previous configuration initially loaded from logback.xml loggerContext.reset(); JoranConfigurator configurator = new JoranConfigurator(); configurator.setContext(loggerContext); try { configurator.doConfigure(configUrl); StatusPrinter.print(loggerContext); } catch(JoranException ex) { StatusPrinter.print(loggerContext); } } } with a file containing <?xml version="1.0" encoding="UTF-8"?> <configuration> <contextName>Foobar</contextName> [..] </configuration> produces the following error: 12:21:28,919 |-ERROR in ch.qos.logback.classic.joran.action.ContextNameAction - Failed to rename context [Foo] as [Foobar] java.lang.IllegalStateException: Context has been already given a name at java.lang.IllegalStateException: Context has been already given a name at at ch.qos.logback.core.ContextBase.setName(ContextBase.java:128) at at ch.qos.logback.classic.LoggerContext.setName(LoggerContext.java:107) at at ch.qos.logback.classic.joran.action.ContextNameAction.body(ContextNameAction.java:31) at at ch.qos.logback.core.joran.spi.Interpreter.callBodyAction(Interpreter.java:296) at at ch.qos.logback.core.joran.spi.Interpreter.characters(Interpreter.java:176) at at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:57) at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:157) at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:143) at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:106) at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:56) Is this expected behavior? After all, loggerContext.reset() has been called and I'd assume that this would also reset the contextName. Feels like a bug.

    QOS.ch JIRA | 4 years ago | Joern Huxhorn
    java.lang.IllegalStateException: Context has been already given a name
  3. 0

    Forcing spring.application.name property to 'bootstrap' breaks Logback config

    GitHub | 6 months ago | aantono
    java.lang.IllegalStateException: Context has been already given a name
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Java Service Wrapper / Discussion / Help:Wrapper Service Stops after starting

    sourceforge.net | 5 months ago
    java.lang.IllegalStateException: WrapperManager has already been started with a WrapperListener.
  6. 0

    IllegalStateException: A factory has already been set on this LayoutInflater

    GitHub | 2 years ago | dkokic
    java.lang.IllegalStateException: A factory has already been set on this LayoutInflater

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.IllegalStateException

      Context has been already given a name

      at ch.qos.logback.core.ContextBase.setName()
    2. Logback Core Module
      ContextBase.setName
      1. ch.qos.logback.core.ContextBase.setName(ContextBase.java:128)
      1 frame
    3. Logback Classic Module
      ContextNameAction.body
      1. ch.qos.logback.classic.LoggerContext.setName(LoggerContext.java:107)
      2. ch.qos.logback.classic.joran.action.ContextNameAction.body(ContextNameAction.java:31)
      2 frames
    4. Logback Core Module
      GenericConfigurator.doConfigure
      1. ch.qos.logback.core.joran.spi.Interpreter.callBodyAction(Interpreter.java:296)
      2. ch.qos.logback.core.joran.spi.Interpreter.characters(Interpreter.java:176)
      3. ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:57)
      4. ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:157)
      5. ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:143)
      6. ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:106)
      7. ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:56)
      7 frames