Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-2893

CXF should use class' classloader for initialization of its loggers

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Trivial
    • Resolution: Fixed
    • 2.2.9
    • 2.2.10
    • None
    • None

    Description

      The class org.apache.cxf.common.logging.LogUtils should attempt to use plain Class.forName(cname) if Class.forName(cname, true, Thread.currentThread().getContextClassLoader()) fails.

      Rationale: Current thread might not be able to access cxf classes. Take as an example the following OSGi bundles:
      1) bundle with a http server.
      2) bundle with CXF-based servlet SomeCXFServlet. The bundle contains CXF as private OSGi library.
      A servlet SomeCXFServlet from bundle (2) has access to CXF via SomeCXFServlet.class.getClassloader(), similarly LogUtils class via its classloader. However, the servlet initialization is performed from http server thread that does not have access to bundle (2) private classes. Initialization of a logger is hence also made from the http thread. CXF tries to load its org.apache.cxf.common.logging.*Logger classes - the attempt however fails because the current thread's classloader is used instead of the LogUtils'.

      Solution: Try to load the class using Class.forName(cname) if Class.forName(cname, true, Thread.currentThread().getContextClassLoader()) fails.

      Will attach diff in a separate comment

      Attachments

        1. patch.diff
          1 kB
          Hynek Mlnarik

        Activity

          People

            dkulp Daniel Kulp
            hmlnarik Hynek Mlnarik
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: