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

NullPointerException in org.apache.logging.log4j.util.LoaderUtil.getClassLoaders() when using Bootstrap class loader

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Fixed
    • 2.9.1, 2.10.0, 2.11.0
    • 2.11.1, 3.0.0
    • API
    • None

    Description

      When log4j2 classes are loaded via the Bootstrap classloader, creating a Logger (LogManager.getLogger()) causes a NullPointerException:

      Exception in thread "main" java.lang.ExceptionInInitializerError
      	at Test.<clinit>(Test.java:6)
      Caused by: java.lang.NullPointerException
      	at org.apache.logging.log4j.util.LoaderUtil.getClassLoaders(LoaderUtil.java:115)
      	at org.apache.logging.log4j.util.ProviderUtil.<init>(ProviderUtil.java:66)
      	at org.apache.logging.log4j.util.ProviderUtil.lazyInit(ProviderUtil.java:146)
      	at org.apache.logging.log4j.util.ProviderUtil.hasProviders(ProviderUtil.java:130)
      	at org.apache.logging.log4j.LogManager.<clinit>(LogManager.java:89)
      	... 1 more
      

      To reproduce this behavior I put the log4j jar files (log4j-api and log4j-core) into a dedicated directory and start my test program with -Djava.endorsed.dirs=dirname. Classes from jars in that directory are loaded using the Bootstrap classloader.

       

      The issue came with 2.9.1. It worked with 2.9.0 and earlier versions.

      Attachments

        Activity

          People

            Unassigned Unassigned
            mirko24 Mirko Rzehak
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: