users@glassfish.java.net

Loading Classes in at Runtime - NoClassDefFound

From: <glassfish_at_javadesktop.org>
Date: Tue, 02 Dec 2008 07:15:01 PST

Hello,

I'm writing a piece of software that includes a Swing Application that clients will use to connect to a Web App running on Glassfish via Web Services.

Basically, clients will write java classes implementing my interface (AlgorithmInterface), and browse to the class files from the Swing App. They can then choose a problem class to run against - these are ".class" files stored on the server.

Values would then be passed back and forth between the classes using web services:
AlgorithmInterface class <--> Web Service <--> ProblemInterface Class

I have written a subclass of ClassLoader to help load in classes at run time - it can take the directory the user specified, find all the ".class" files, and filter them for ones that implement "AlgorithmInterface".

I thought I could just re-use this code on the server side, so that it could dynamically load in classes that implement ProblemInterface (as opposed to AlgorithmInterface on the client). However, when trying to load a class, the exception "NoClassDefFound" is thrown, and then the name of my interface. Apparently its not finding ProblemInterface.

Is what I'm trying to do impossible on an application server? Maybe it handles ClassLoader differently? It looks like it has no idea what ProblemInterface is. I've tried putting it in the lib/classes folder, importing it in classes and stuff, but no luck.

Sorry about the long-winded post, I tried to be as brief as possible but it's a fairly niggly problem! If anyone could offer any words of advice it would help me in a huuuuuge way!

Thanks!
[Message sent by forum member 'calmdownmonkey' (calmdownmonkey)]

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