Details
-
Bug
-
Status: Closed
-
Critical
-
Resolution: Fixed
-
1.0.4
-
None
-
Operating System: All
Platform: Macintosh
-
31710
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