Commons Logging
  1. Commons Logging
  2. LOGGING-33

getClassLoader() returns null at a critical point under certain conditions

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 1.0.4
    • Fix Version/s: 1.1.0
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: Macintosh

      Description

      launching jakarta-tomcat 5.0.28 using the JWS (java wrapper service) via the
      Bootstrap class leads to a critical null pointer exception which points to code
      in LogFactoryImpl.java which expects this.getClass().getClassLoader() to return
      a value that's not null. The javadocs for Class state that null can be returned
      in some implementations if the class was loaded by the bootstrap classloader. I
      have a patch file but am not sure how to submit it as an attachment so here it
      is below:

      Index: LogFactoryImpl.java
      ===================================================================
      RCS file:
      /home/cvspublic/jakarta-commons/logging/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java,v
      retrieving revision 1.33
      diff -u -u -r1.33 LogFactoryImpl.java
      — LogFactoryImpl.java 6 Mar 2004 21:52:59 -0000 1.33
      +++ LogFactoryImpl.java 13 Oct 2004 20:54:02 -0000
      @@ -371,8 +371,12 @@
      Class logClass = null;
      Class logInterface = null;
      try {

      • logInterface = this.getClass().getClassLoader().loadClass
      • (LOG_INTERFACE);
        + ClassLoader cl = this.getClass().getClassLoader();
        + // handle the case if getClassLoader() returns null
        + // It may mean this class was loaded from the bootstrap classloader
        + logInterface = (cl == null) ? loadClass(LOG_INTERFACE) :
        + cl.loadClass(LOG_INTERFACE);
        +
        logClass = loadClass(logClassName);
        if (logClass == null) {
        throw new LogConfigurationException

        Activity

        Hide
        David Ferrero added a comment -

        Created an attachment (id=13085)
        patch to fix null pointer for this bug.

        Show
        David Ferrero added a comment - Created an attachment (id=13085) patch to fix null pointer for this bug.
        Hide
        rdonkin@apache.org added a comment -

        Committed. Many Thanks.

        Robert

        Show
        rdonkin@apache.org added a comment - Committed. Many Thanks. Robert

          People

          • Assignee:
            Unassigned
            Reporter:
            David Ferrero
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development