tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joe user <>
Subject Using a custom class loader to load webapp classes
Date Tue, 01 Jul 2003 01:00:07 GMT
Hello Tomcatters,

I have an unusual question.  I have a webapp which
needs to load its classes from a source other than a
regular .jar file or a .class file.  It needs to get
them out of some other storage system, such as a
database.  Don't ask me why I need to do this strange
thing; I have my reasons for it.

I have written a subclass of ClassLoader which does
this.  The question is, how do I get this to work with
Tomcat?  I was looking at the Tomcat source, and it
looks like all Webapp classes are loaded by
org.apache.catalina.loader.WebappClassLoader, which is
a subclass of URLClassLoader.  I can easily write a
subclass of WebappClassLoader which does what I need
it to do.  The question is, how do I get Tomcat to use
my new subclass instead of the default
WebappClassLoader itself?

I looked in org.apache.catalina.loader.WebappLoader,
and see that it picks the webapp class loader by name,
and it has a method like this:

    public void setLoaderClass(String loaderClass) {
        this.loaderClass = loaderClass;

Is there somewhere in the Tomcat config files where I
could set a string which gets passed to this method? 
Also, if I do make my own subclass of
WebappClassLoader (call it SecureWebappClassLoader),
where should that class be put into the Tomcat
directory structure so that it can get loaded?

Thanks for any advice on this unusual question.

Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message