Re: Strange noclassdefnotfounderror with custom classloader
Berlin Brown wrote:
I believe I Get this errror because there are multiple "classes" on
the same name in the classpath from two different jars and I guess the
classloader is confused?
You get this error because the class loader can't find the class. The
Java class loaders have no problems dealing with multiple definitions of
classes (they use the first one they find).
Generally speaking, class loaders implement a successive fallback
scheme: if a class loader can't find a class, it asks its parent class
loader to find it. I'm guessing you don't have this fallback working.
Do you know how to diagnose these problems, should I build a more
robust classloader.
As far as classloader problems go, this is rather simple. All you need
to do is figure out which classloader is having problems finding the
class and then work out the fallback hierarchy to figure out what is
missing and where it needs to go.
A real classloader problem that I've had--and which you might run
into--is this fun exception:
ClassCastException: class util.Option could not be cast to class
util.Option.
--
Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth