Uploaded image for project: 'SLF4J'
  1. SLF4J
  2. SLF4J-137

NullPointerException when getILoggerFactory()

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Fixed
    • None
    • 1.5.x
    • Core API
    • None
    • Operating System: Windows XP
      Platform: PC

    Description

      I got this exception when I run my class in Eclipse:
      log = LoggerFactory.getLogger(SilenceInstall.class);

      Exception in thread "main" java.lang.NullPointerException
      at org.slf4j.LoggerFactory.singleImplementationSanityCheck(LoggerFactory.java:192)
      at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:113)
      at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:269)
      at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:242)
      at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:255)
      at
      com.foo.installation.SilenceInstall.main(SilenceInstall.java:99)

      It is due to LoggerFactory.class.getClassLoader() returns null in:

      private static void singleImplementationSanityCheck() {
      try {
      Enumeration paths = LoggerFactory.class.getClassLoader().getResources(
      STATIC_LOGGER_BINDER_PATH);
      ....

      According to JavaDoc, getClassLoader() can be null: "Some implementations may use null to represent the bootstrap class loader. "

      Attachments

        Activity

          People

            slf4j-dev SLF4J developers list
            dapeng.ni@edgenius.com Dapeng
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: