java.lang.IllegalStateException: contextSelector cannot be null. See also http://logback.qos.ch/codes.html#null_CS

QOS.ch JIRA | todd orr | 9 years ago
  1. 0

    I'm not sure exactly what's going on, but I've been able to determine that the JMS appender doesn't work under certain circumstances due to some interaction with commons logging. Here is my maven POM: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>foo.bar</groupId> <artifactId>testbed</artifactId> <name>Testbed</name> <packaging>jar</packaging> <version>0.1-SNAPSHOT</version> <build> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.5</source> <target>1.5</target> </configuration> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>org.apache.activemq</groupId> <artifactId>activemq-core</artifactId> <version>5.0.0</version> <exclusions> <exclusion> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> </exclusion> <exclusion> <groupId>commons-logging</groupId> <artifactId>commons-logging-api</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.4.3</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>jcl104-over-slf4j</artifactId> <version>1.4.3</version> </dependency> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-core</artifactId> <version>0.9.9</version> </dependency> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> <version>0.9.9</version> </dependency> </dependencies> </project> Here is my logback config: <configuration debug="true"> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <layout class="ch.qos.logback.classic.PatternLayout"> <Pattern> %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n </Pattern> </layout> </appender> <!-- <appender name="QUEUE" class="ch.qos.logback.classic.net.JMSQueueAppender"> <InitialContextFactoryName> org.apache.activemq.jndi.ActiveMQInitialContextFactory </InitialContextFactoryName> <ProviderURL>tcp://localhost:61616</ProviderURL> <QueueConnectionFactoryBindingName> ConnectionFactory </QueueConnectionFactoryBindingName> <QueueBindingName>dynamicQueues/queue.foo.logger</QueueBindingName> </appender> <logger name="foo.bar.testbed"> <level value="DEBUG" /> <appender-ref ref="QUEUE" /> </logger> --> <root> <level value="TRACE" /> <appender-ref ref="STDOUT" /> </root> </configuration> Uncommenting the QUEUE appender results in the following stack trace: Failed to instantiate [ch.qos.logback.classic.LoggerContext] Reported exception: java.lang.ExceptionInInitializerError at org.apache.activemq.ActiveMQConnectionFactory.<init>(ActiveMQConnectionFactory.java:88) at org.apache.activemq.ActiveMQConnectionFactory.<init>(ActiveMQConnectionFactory.java:121) at org.apache.activemq.ActiveMQConnectionFactory.<init>(ActiveMQConnectionFactory.java:117) at org.apache.activemq.jndi.ActiveMQInitialContextFactory.createConnectionFactory(ActiveMQInitialContextFactory.java:201) at org.apache.activemq.jndi.ActiveMQInitialContextFactory.createConnectionFactory(ActiveMQInitialContextFactory.java:140) at org.apache.activemq.jndi.ActiveMQInitialContextFactory.getInitialContext(ActiveMQInitialContextFactory.java:65) at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667) at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247) at javax.naming.InitialContext.init(InitialContext.java:223) at javax.naming.InitialContext.<init>(InitialContext.java:197) at ch.qos.logback.core.net.JMSAppenderBase.buildJNDIContext(JMSAppenderBase.java:49) at ch.qos.logback.classic.net.JMSQueueAppender.start(JMSQueueAppender.java:89) at ch.qos.logback.core.joran.action.AppenderAction.end(AppenderAction.java:89) at ch.qos.logback.core.joran.spi.Interpreter.callEndAction(Interpreter.java:310) at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:173) at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:154) at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:48) at ch.qos.logback.core.joran.spi.Interpreter.play(Interpreter.java:336) at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:96) at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:74) at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:38) at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:23) at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:34) at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:43) at org.slf4j.impl.StaticLoggerBinder.initialize(StaticLoggerBinder.java:62) at org.slf4j.impl.StaticLoggerBinder.<init>(StaticLoggerBinder.java:53) at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:48) at org.slf4j.LoggerFactory.<clinit>(LoggerFactory.java:60) at foo.bar.testbed.LoggerTester.main(LoggerTester.java:9) Caused by: java.lang.IllegalStateException: Logging factory implementation cannot be null. See also http://www.slf4j.org/codes.html#null_LF at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:86) 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:204) at org.apache.activemq.ActiveMQPrefetchPolicy.<clinit>(ActiveMQPrefetchPolicy.java:30) ... 29 more Failed to instantiate logger [ch.qos.logback.classic.selector.ContextSelector] Reported exception: java.lang.IllegalStateException: contextSelector cannot be null. See also http://logback.qos.ch/codes.html#null_CS at org.slf4j.impl.StaticLoggerBinder.getLoggerFactory(StaticLoggerBinder.java:98) at org.slf4j.LoggerFactory.<clinit>(LoggerFactory.java:60) at foo.bar.testbed.LoggerTester.main(LoggerTester.java:9) Exception in thread "main" java.lang.IllegalStateException: Logging factory implementation cannot be null. See also http://www.slf4j.org/codes.html#null_LF at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:101) at foo.bar.testbed.LoggerTester.main(LoggerTester.java:9) However, removing the SLF4J commons bridge and un-excluding the commons libs from activemq results in the correct behavior. At this point the commons logging is not running through SLF4J at this point. So this is not desirable.

    QOS.ch JIRA | 9 years ago | todd orr
    java.lang.IllegalStateException: contextSelector cannot be null. See also http://logback.qos.ch/codes.html#null_CS
  2. 0

    I'm not sure exactly what's going on, but I've been able to determine that the JMS appender doesn't work under certain circumstances due to some interaction with commons logging. Here is my maven POM: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>foo.bar</groupId> <artifactId>testbed</artifactId> <name>Testbed</name> <packaging>jar</packaging> <version>0.1-SNAPSHOT</version> <build> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.5</source> <target>1.5</target> </configuration> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>org.apache.activemq</groupId> <artifactId>activemq-core</artifactId> <version>5.0.0</version> <exclusions> <exclusion> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> </exclusion> <exclusion> <groupId>commons-logging</groupId> <artifactId>commons-logging-api</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.4.3</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>jcl104-over-slf4j</artifactId> <version>1.4.3</version> </dependency> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-core</artifactId> <version>0.9.9</version> </dependency> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> <version>0.9.9</version> </dependency> </dependencies> </project> Here is my logback config: <configuration debug="true"> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <layout class="ch.qos.logback.classic.PatternLayout"> <Pattern> %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n </Pattern> </layout> </appender> <!-- <appender name="QUEUE" class="ch.qos.logback.classic.net.JMSQueueAppender"> <InitialContextFactoryName> org.apache.activemq.jndi.ActiveMQInitialContextFactory </InitialContextFactoryName> <ProviderURL>tcp://localhost:61616</ProviderURL> <QueueConnectionFactoryBindingName> ConnectionFactory </QueueConnectionFactoryBindingName> <QueueBindingName>dynamicQueues/queue.foo.logger</QueueBindingName> </appender> <logger name="foo.bar.testbed"> <level value="DEBUG" /> <appender-ref ref="QUEUE" /> </logger> --> <root> <level value="TRACE" /> <appender-ref ref="STDOUT" /> </root> </configuration> Uncommenting the QUEUE appender results in the following stack trace: Failed to instantiate [ch.qos.logback.classic.LoggerContext] Reported exception: java.lang.ExceptionInInitializerError at org.apache.activemq.ActiveMQConnectionFactory.<init>(ActiveMQConnectionFactory.java:88) at org.apache.activemq.ActiveMQConnectionFactory.<init>(ActiveMQConnectionFactory.java:121) at org.apache.activemq.ActiveMQConnectionFactory.<init>(ActiveMQConnectionFactory.java:117) at org.apache.activemq.jndi.ActiveMQInitialContextFactory.createConnectionFactory(ActiveMQInitialContextFactory.java:201) at org.apache.activemq.jndi.ActiveMQInitialContextFactory.createConnectionFactory(ActiveMQInitialContextFactory.java:140) at org.apache.activemq.jndi.ActiveMQInitialContextFactory.getInitialContext(ActiveMQInitialContextFactory.java:65) at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667) at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247) at javax.naming.InitialContext.init(InitialContext.java:223) at javax.naming.InitialContext.<init>(InitialContext.java:197) at ch.qos.logback.core.net.JMSAppenderBase.buildJNDIContext(JMSAppenderBase.java:49) at ch.qos.logback.classic.net.JMSQueueAppender.start(JMSQueueAppender.java:89) at ch.qos.logback.core.joran.action.AppenderAction.end(AppenderAction.java:89) at ch.qos.logback.core.joran.spi.Interpreter.callEndAction(Interpreter.java:310) at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:173) at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:154) at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:48) at ch.qos.logback.core.joran.spi.Interpreter.play(Interpreter.java:336) at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:96) at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:74) at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:38) at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:23) at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:34) at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:43) at org.slf4j.impl.StaticLoggerBinder.initialize(StaticLoggerBinder.java:62) at org.slf4j.impl.StaticLoggerBinder.<init>(StaticLoggerBinder.java:53) at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:48) at org.slf4j.LoggerFactory.<clinit>(LoggerFactory.java:60) at foo.bar.testbed.LoggerTester.main(LoggerTester.java:9) Caused by: java.lang.IllegalStateException: Logging factory implementation cannot be null. See also http://www.slf4j.org/codes.html#null_LF at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:86) 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:204) at org.apache.activemq.ActiveMQPrefetchPolicy.<clinit>(ActiveMQPrefetchPolicy.java:30) ... 29 more Failed to instantiate logger [ch.qos.logback.classic.selector.ContextSelector] Reported exception: java.lang.IllegalStateException: contextSelector cannot be null. See also http://logback.qos.ch/codes.html#null_CS at org.slf4j.impl.StaticLoggerBinder.getLoggerFactory(StaticLoggerBinder.java:98) at org.slf4j.LoggerFactory.<clinit>(LoggerFactory.java:60) at foo.bar.testbed.LoggerTester.main(LoggerTester.java:9) Exception in thread "main" java.lang.IllegalStateException: Logging factory implementation cannot be null. See also http://www.slf4j.org/codes.html#null_LF at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:101) at foo.bar.testbed.LoggerTester.main(LoggerTester.java:9) However, removing the SLF4J commons bridge and un-excluding the commons libs from activemq results in the correct behavior. At this point the commons logging is not running through SLF4J at this point. So this is not desirable.

    QOS.ch JIRA | 9 years ago | todd orr
    java.lang.IllegalStateException: contextSelector cannot be null. See also http://logback.qos.ch/codes.html#null_CS
  3. 0

    Reg. java Connection to Titan+Hbase (too may jars compatibility issue)

    Google Groups | 1 year ago | deepak dabi
    java.lang.IllegalStateException: contextSelector cannot be null. See also http://logback.qos.ch/codes.html#null_CS
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Logback Issue

    GitHub | 4 years ago | timothymdavis
    org.infernus.idea.checkstyle.exception.CheckStylePluginException: An error occurred during a file scan.
  6. 0

    I'm not sure exactly what's going on, but I've been able to determine that the JMS appender doesn't work under certain circumstances due to some interaction with commons logging. Here is my maven POM: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>foo.bar</groupId> <artifactId>testbed</artifactId> <name>Testbed</name> <packaging>jar</packaging> <version>0.1-SNAPSHOT</version> <build> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.5</source> <target>1.5</target> </configuration> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>org.apache.activemq</groupId> <artifactId>activemq-core</artifactId> <version>5.0.0</version> <exclusions> <exclusion> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> </exclusion> <exclusion> <groupId>commons-logging</groupId> <artifactId>commons-logging-api</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.4.3</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>jcl104-over-slf4j</artifactId> <version>1.4.3</version> </dependency> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-core</artifactId> <version>0.9.9</version> </dependency> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> <version>0.9.9</version> </dependency> </dependencies> </project> Here is my logback config: <configuration debug="true"> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <layout class="ch.qos.logback.classic.PatternLayout"> <Pattern> %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n </Pattern> </layout> </appender> <!-- <appender name="QUEUE" class="ch.qos.logback.classic.net.JMSQueueAppender"> <InitialContextFactoryName> org.apache.activemq.jndi.ActiveMQInitialContextFactory </InitialContextFactoryName> <ProviderURL>tcp://localhost:61616</ProviderURL> <QueueConnectionFactoryBindingName> ConnectionFactory </QueueConnectionFactoryBindingName> <QueueBindingName>dynamicQueues/queue.foo.logger</QueueBindingName> </appender> <logger name="foo.bar.testbed"> <level value="DEBUG" /> <appender-ref ref="QUEUE" /> </logger> --> <root> <level value="TRACE" /> <appender-ref ref="STDOUT" /> </root> </configuration> Uncommenting the QUEUE appender results in the following stack trace: Failed to instantiate [ch.qos.logback.classic.LoggerContext] Reported exception: java.lang.ExceptionInInitializerError at org.apache.activemq.ActiveMQConnectionFactory.<init>(ActiveMQConnectionFactory.java:88) at org.apache.activemq.ActiveMQConnectionFactory.<init>(ActiveMQConnectionFactory.java:121) at org.apache.activemq.ActiveMQConnectionFactory.<init>(ActiveMQConnectionFactory.java:117) at org.apache.activemq.jndi.ActiveMQInitialContextFactory.createConnectionFactory(ActiveMQInitialContextFactory.java:201) at org.apache.activemq.jndi.ActiveMQInitialContextFactory.createConnectionFactory(ActiveMQInitialContextFactory.java:140) at org.apache.activemq.jndi.ActiveMQInitialContextFactory.getInitialContext(ActiveMQInitialContextFactory.java:65) at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667) at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247) at javax.naming.InitialContext.init(InitialContext.java:223) at javax.naming.InitialContext.<init>(InitialContext.java:197) at ch.qos.logback.core.net.JMSAppenderBase.buildJNDIContext(JMSAppenderBase.java:49) at ch.qos.logback.classic.net.JMSQueueAppender.start(JMSQueueAppender.java:89) at ch.qos.logback.core.joran.action.AppenderAction.end(AppenderAction.java:89) at ch.qos.logback.core.joran.spi.Interpreter.callEndAction(Interpreter.java:310) at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:173) at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:154) at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:48) at ch.qos.logback.core.joran.spi.Interpreter.play(Interpreter.java:336) at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:96) at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:74) at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:38) at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:23) at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:34) at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:43) at org.slf4j.impl.StaticLoggerBinder.initialize(StaticLoggerBinder.java:62) at org.slf4j.impl.StaticLoggerBinder.<init>(StaticLoggerBinder.java:53) at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:48) at org.slf4j.LoggerFactory.<clinit>(LoggerFactory.java:60) at foo.bar.testbed.LoggerTester.main(LoggerTester.java:9) Caused by: java.lang.IllegalStateException: Logging factory implementation cannot be null. See also http://www.slf4j.org/codes.html#null_LF at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:86) 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:204) at org.apache.activemq.ActiveMQPrefetchPolicy.<clinit>(ActiveMQPrefetchPolicy.java:30) ... 29 more Failed to instantiate logger [ch.qos.logback.classic.selector.ContextSelector] Reported exception: java.lang.IllegalStateException: contextSelector cannot be null. See also http://logback.qos.ch/codes.html#null_CS at org.slf4j.impl.StaticLoggerBinder.getLoggerFactory(StaticLoggerBinder.java:98) at org.slf4j.LoggerFactory.<clinit>(LoggerFactory.java:60) at foo.bar.testbed.LoggerTester.main(LoggerTester.java:9) Exception in thread "main" java.lang.IllegalStateException: Logging factory implementation cannot be null. See also http://www.slf4j.org/codes.html#null_LF at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:101) at foo.bar.testbed.LoggerTester.main(LoggerTester.java:9) However, removing the SLF4J commons bridge and un-excluding the commons libs from activemq results in the correct behavior. At this point the commons logging is not running through SLF4J at this point. So this is not desirable.

    QOS.ch JIRA | 9 years ago | todd orr
    java.lang.IllegalStateException: Logging factory implementation cannot be null. See also http://www.slf4j.org/codes.html#null_LF

    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

      contextSelector cannot be null. See also http://logback.qos.ch/codes.html#null_CS

      at org.slf4j.impl.StaticLoggerBinder.getLoggerFactory()
    2. SLF4J LOG4J-12 Binding
      StaticLoggerBinder.getLoggerFactory
      1. org.slf4j.impl.StaticLoggerBinder.getLoggerFactory(StaticLoggerBinder.java:98)
      1 frame
    3. SLF4J API Module
      LoggerFactory.<clinit>
      1. org.slf4j.LoggerFactory.<clinit>(LoggerFactory.java:60)
      1 frame
    4. foo.bar.testbed
      LoggerTester.main
      1. foo.bar.testbed.LoggerTester.main(LoggerTester.java:9)
      1 frame