Discussion:
Can't load external classes - ClassNotFoundError
(too old to reply)
Gary
2006-03-08 13:50:38 UTC
Permalink
I want to load an external class (i.e. one in a local disk directory,
not part of the distribution EAR file). But I can't figure out what's
wrong.

1. I added the root directory, \opt\deployment_root\classes, to my
CLASSPATH before starting weblogic.
2. I created the java file GaryTestEventHandler.java

package com.maximus.stt.app.schoolmax.handlers;
// imports here
public class GaryTestEventHandler implements IAlertsEventHandler {
public void handle(UserContext uc, AlertsEventDef aed, KeySet
keySetIn, Context context, Map params, Map entities) {
System.out.println ("$$$$$$$$ GaryTestEventHandler called,
entities="+entities);
}
}

I compiled this file normally using Eclipse. So in the directory
\opt\deployment_root\classes\com\maximus\stt\app\schoolmax\handlers
there's now a file GaryTestEventHandler.class.

3. I try to do a
Class.forName("com.maximus.stt.app.schoolmax.handlers.GaryTestEventHandler")
and it throws a NoClassDefFoundError. This is in a static method of a
class.

4. But if I try

ClassLoader.getSystemClassLoader().getResourceAsStream("com/maximus/stt/app/schoolmax/handlers/GaryTestEventHandler.class");

it works fine.

I'm baffled. Any ideas? Thanks.
Gary
2006-03-09 14:15:01 UTC
Permalink
Note also, that what I get is a NoClassDefFoundError, not a
ClassNotFoundException. If it just can't find the class, I'd expect the
latter. It's like at first it can find the class, but then when it
attempts to actually load it, it fails.

Loading...