commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 31710] New: - getClassLoader() returns null at a critical point under certain conditions
Date Wed, 13 Oct 2004 21:24:46 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=31710>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=31710

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

           Summary: getClassLoader() returns null at a critical point under
                    certain conditions
           Product: Commons
           Version: 1.0.4
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: Critical
          Priority: Other
         Component: Logging
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: david.ferrero@zion.com
                CC: david.ferrero@zion.com


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

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message