From: "KAKARONTZAS GEORGE" <[EMAIL PROTECTED]>
Sent: Wednesday, July 10, 2002 11:04 PM


> Hi all,
> I'm building a system that must be able to execute any java app that
> will be uploaded.
> In fact the server (a web app running under tomcat) just dispatches
> these applications to other pcs.
> The problem is that while the server serializes the application class
> files for dispatching I get a HTTP 500 error on the pcs that want to
> execute the code.
> I'm not getting this if I copy the app files (contained in a jar) in the
> WEB-INF/lib before starting tomcat.
> So I concluded that the reason for the error is that this jar file is
> not in the classpath of the web application class loader.
> First I want to ask if you agree with that.
> Second, if you do is there a way to add a jar file in the web
> application class loader classpath, while the application is running.
> Note that I modified the code so that the jar file is copied in
> WEB-INF/lib after uploading, but that didn't work.

I can't say about the 500 error, as that can be most anything.

But, let's discuss the Jar file issue.

The problem with the Jar file is that it must physically appear on the
CLASSPATH of the ClassLoader for it to be considered, and I don't know of a
way to dynamically update the CLASSPATH that would actually affect the
ClassLoader. In theory you might be able to simply change the
java.class.path System property, but I'd be very surprised if that worked. I
would think that the ClassLoader would only read that when it's instantiated
and pretty much ignore it afterward.

One solution, though, is to reserve an actual directory that is on the
CLASSPATH and then rather than simply copying the Jar files, actually
explode them into that directory. Java's default ClassLoaders seem to pick
up new classes within directories that already exist on the CLASSPATH.

So, if a Jar was exploded into a directory already on the CLASSPATH (i.e.
being monitored by the Java ClassLoaders), then, in theory, those classes
would be dynamically loadable into a running JVM.

Now, of course, you will have a problem RE loading those applications and
classes without a restart, but that's a different topic.

Finally, this is all designed to work around the existing ClassLoaders. The
real solution is to write your own ClassLoader, and solve it that way.

In the 3.2 Tomcat, there's a file
org.apache.tomcat.loader.AdaptiveClassLoader (I don't have the 4.x source
handy). That can serve as an inspiration.

Best Regards,

Will Hartung
([EMAIL PROTECTED])




--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to