users@glassfish.java.net

How to add a JAR to the runtime classpath?

From: <glassfish_at_javadesktop.org>
Date: Tue, 16 Dec 2008 14:58:45 PST

I am using Netbeans 6.1 with GF2r1.

I am tearing my hair out trying to fix a NoClassDefFoundError that occurs at runtime in my MDB, when it is first created and tries to access a [b]utility[/b] class (in a separate jar).

I have listed the jar in the compile section of the EJB project's properties in NB, with "package" ticked, and the utility jar is definitely in the MDB's jar file, but for some reason the MDB cannot find it at runtime.

I realise the difference between NoClassDefFoundError and ClassNotFoundException and have determined that in fact the problem occurs when I try to create an instance of utility class A (in A.jar) which itself tries to create an instance of utility class B (in B.jar) [both jars are setup as described above in NB]. The Error reports that it cannot find class B (not A), so perhaps there is some ordering problem, though I thought that didn't happen in Java (?).

Any thoughts or suggestions on how to track this down would be appreciated. I have tried:
- Class.forName("A") before the new - works fine.
- Class.forName("B") before the new - works fine.
- Copying the jar files into GF's lib directory and updating the references - no change.

TIA, m.
[Message sent by forum member 'matterbury' (matterbury)]

http://forums.java.net/jive/thread.jspa?messageID=321986