tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christopher K. St. John" <>
Subject Re: Replacing WebappClassLoader
Date Wed, 24 Apr 2002 18:07:33 GMT
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 org.apache.catalina.*;
import org.apache.catalina.loader.*;

public class TestLoader extends WebappLoader {
  public TestLoader(ClassLoader parent) {
  public void setDebug(int debug) {
  public void start() throws LifecycleException {
    // instead of super.start(), do your own thing here

 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
> 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(

 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

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

View raw message