Volker Leidl wrote:
I tried to configure tomcat 4.0.2 to use my own class loader implementation
for web-app class loading. The documentation implies that this can be done
by secifying a loaderClass attribute in my Context/Loader element in
server.xml.
Loader specifies an org.apache.catalina.Loader object, not an
java.lang.ClassLoader. You'd need to do something like this:
package com.distributopia.mtc;
import java.io.*;
import org.apache.catalina.*;
import org.apache.catalina.loader.*;
public class TestLoader extends WebappLoader {
public TestLoader(ClassLoader parent) {
super(parent);
System.out.println(TestLoader.TestLoader(+parent+));
}
public void setDebug(int debug) {
System.out.println(TestLoader.setDebug(+debug+));
super.setDebug(debug);
}
public void start() throws LifecycleException {
System.out.println(TestLoader.start());
// instead of super.start(), do your own thing here
super.start();
}
}
Compile it, jar it up, copy it over to $TOMCAT_HOME/server/lib,
and you're set. Sort of.
Stepping through the code of org.apache.catalina.loader.WebappLoader (which
i still want to use) I found out that the loaderClass Property does get set,
but it seems to be ignored since
org.apache.catalina.loader.WebappClassLoader gets instantiated explicitly
(line 615-, cvs revision 1.12.2.5).
Is this intended? Perhaps I missed something in the code.
What the example above does is override the start() method. It
just re-dispatches it to the original, but what you'd need to do
is reimplement it to use your classloader, instead of the one
WebAppClassLoader uses.
This does not work.
Actually, neither does my suggestion, at leat not on HEAD. I
could have sworn it used to work, but maybe I just wasn't paying
enough attention to the log messages. Anyway, running the above
I get this:
ServerLifecycleListener: createMBeans: MBeanException
java.lang.Exception: ManagedBean is not found with TestLoader
at org.apache.catalina.mbeans.MBeanUtils.createMBean(MBeanUtils.java:374)
I'll test further, but first I wanted to get some feedback on
whether I've made some stupid mistake. I kinda sorta half
suspect this is related to the way Tomcat hardcodes all the
MBeans instead of generating them dynamically using reflection,
but I'm very unsure about it.
--
Christopher St. John [EMAIL PROTECTED]
DistribuTopia http://www.distributopia.com
--
To unsubscribe, e-mail: mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]