From: | Oliver Jowett <oliver(at)opencloud(dot)com> |
---|---|
To: | Robin Rosenberg <robin(dot)rosenberg(dot)lists(at)dewire(dot)com> |
Cc: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: NoClassDefFoundErrors |
Date: | 2009-03-18 09:20:52 |
Message-ID: | 49C0BCF4.6020609@opencloud.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
Robin Rosenberg wrote:
> Indeed it is there. NoClassDefFoundError is ofter confused with ClassNotFoundException.
>
> NoClassDefFoundError means the class was found, but it couldn't be loaded because
> of another class was needed for the base class or interface or an exception was thrown
> in a static initializer during class loading. There might be other reasons, but those are
> the ones I know about. The problem is that these errors are very hard to debug, so I was
> hoping for a clue.
I do understand the difference between the two.
NoClassDefFoundError doesn't behave as you describe. It means, as the
name says, that the named class could not be loaded.
It's thrown as a *result* of trying to resolve the named class, perhaps
because it is named as a base class or interface during classloading of
another class, or because it's referenced by a method descriptor that
needs to be resolved (some time after classloading). In this case, the
JVM is trying to resolve a call from QueryExecutorImpl (which is loaded,
initialized, and executing) to a static method on Parser. The first time
such a method is called, the JVM attempts to load and initialize Parser
so that it can resolve the method descriptor. When it cannot find
Parser.class, a NoClassDefFoundError is thrown.
I believe the class named in the NoClassDefFoundError is always the
ultimately missing class. (So if class A exists, but initialization of A
fails because class B does not exist, then you get a
NoClassDefFoundError: B as a result of trying to resolve A)
Incidentally, exceptions in static initializers during class
initialization are reported by an ExceptionInInitializerError, *not*
NoClassDefFoundError.
I would suggest taking a hard look at how Glassfish is loading the
driver classes, sounds like it is mangling things along the way somehow.
-O
From | Date | Subject | |
---|---|---|---|
Next Message | Peter | 2009-03-18 10:13:06 | Re: Totally weird behaviour in org.postgresql.Driver |
Previous Message | Robin Rosenberg | 2009-03-18 08:59:47 | Re: NoClassDefFoundErrors |