>Number: 3329
>Category: mod_jserv
>Synopsis: AdaptiveClassLoader.loadClass returns null --> null pointer
>err in JServServletManager
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: jserv
>State: open
>Class: sw-bug
>Submitter-Id: apache
>Arrival-Date: Sun Nov 1 23:10:00 PST 1998
>Last-Modified:
>Originator: [EMAIL PROTECTED]
>Organization:
apache
>Release: 1.3.3
>Environment:
[EMAIL PROTECTED]:~:1067> uname -a
Linux linux.lan 2.0.35 #1 Tue Jul 14 23:56:39 EDT 1998 i686 unknown
>Description:
There's a bug in the AdaptiveClassLoader.loadClass method.
If a class cannot be found loadClass throws an exception
which is ten caught, setting the return variable "c" to null
(I added a couple of println's to the code):
...
// Attempt to load the class from the system
try {
c = loadSystemClass(name, resolve);
if (c != null) {
if (resolve) resolveClass(c);
return c;
}
} catch (Exception e) {
System.err.println("failed: " + e);
c = null;
}
...
This falls through a bunch of code, eventually hitting
a while loop. But the while loop exits after its first
iteration by returning "c", even if "c" is null. To
summarize the loop:
// Cache entry.
ClassCacheEntry classCache = new ClassCacheEntry();
while (repEnum.hasMoreElements()) {
byte[] classData;
...
System.err.println("Returning");
return c;
}
This null value makes its way back to the caller at line 421
in JServServletManager:
...
servlet = (Servlet) loader.loadClass(classname).newInstance();
...
which causes a null pointer exception. The net effect of this
is to leave the browser waiting for a reply that never comes,
eventually timing out on the client. This is what my error log
contains:
Returning
failed: java.lang.ClassNotFoundException: com/bitmechanic/gsp/GspServlet
Returning
java.lang.NullPointerException
at org.apache.jserv.JServServletManager.load_init(JServServletManager.ja
va:424)
at org.apache.jserv.JServServletManager.loadServlet(JServServletManager.
java:381)
at org.apache.jserv.JServConnection.run(JServConnection.java:298)
at java.lang.Thread.run(Thread.java)
Notice that because the original exception was being swallowed
up, and the null pointer exception had no information on the
source of the error, I had no way of knowing which class it
couldn't find.
Now back to figuring out why it can't find my classes.
>How-To-Repeat:
Not sure, I haven't figured out why it can't find my classes.
>Fix:
>Audit-Trail:
>Unformatted:
[In order for any reply to be added to the PR database, ]
[you need to include <[EMAIL PROTECTED]> in the Cc line ]
[and leave the subject line UNCHANGED. This is not done]
[automatically because of the potential for mail loops. ]
[If you do not include this Cc, your reply may be ig- ]
[nored unless you are responding to an explicit request ]
[from a developer. ]
[Reply only with text; DO NOT SEND ATTACHMENTS! ]