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

ClassNotFoundException for BundleContextSelector when initialising in an OSGi environment

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.1
    • Fix Version/s: 2.6
    • Component/s: API
    • Labels:
      None
    • Environment:

      Apache Felix, Java 8

      Description

      When initialising Log4J2 in an Apache Felix environment, I get the following exception:
      ERROR StatusLogger Unable to create context org.apache.logging.log4j.core.osgi.BundleContextSelector java.lang.ClassNotFoundException: org.apache.logging.log4j.core.osgi.BundleContextSelector not found by org.apache.logging.log4j.api [78]
      at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1556)
      at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:77)
      at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1993)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:260)
      at org.apache.logging.log4j.util.LoaderUtil.loadClass(LoaderUtil.java:117)
      at org.apache.logging.log4j.util.LoaderUtil.newInstanceOf(LoaderUtil.java:136)
      at org.apache.logging.log4j.util.LoaderUtil.newCheckedInstanceOf(LoaderUtil.java:163)
      at org.apache.logging.log4j.core.util.Loader.newCheckedInstanceOf(Loader.java:311)
      at org.apache.logging.log4j.core.impl.Log4jContextFactory.createContextSelector(Log4jContextFactory.java:96)
      at org.apache.logging.log4j.core.impl.Log4jContextFactory.<init>(Log4jContextFactory.java:54)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
      at java.lang.Class.newInstance(Class.java:438)
      at org.apache.logging.log4j.LogManager.<clinit>(LogManager.java:96)
      [...]

      Due to a missing import of the org.apache.logging.log4j.core.osgi package in the API OSGi metadata in its pom

        Attachments

        1. pom.xml
          8 kB
          Jonathan Hanba
        2. patch3.diff
          10 kB
          Ludovic HOCHET
        3. patch2.diff
          0.4 kB
          Ludovic HOCHET
        4. patch.diff
          0.4 kB
          Ludovic HOCHET
        5. LOG4J2-920.zip
          850 kB
          Ludovic HOCHET

          Issue Links

            Activity

              People

              • Assignee:
                jvz Matt Sicker
                Reporter:
                lhochet Ludovic HOCHET
              • Votes:
                2 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: