tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Leon Rosenberg" <>
Subject Implementing own Loader
Date Tue, 05 Sep 2006 14:40:16 GMT

I'm trying to implement an own Loader wraped around the WebappLoader.
My goal is to modify the classloader and to substitute all created
servlets by own proxies.

However, I started creating an own loader and proxying requests to the
WebappLoader but failed :-)

My context.xml contains:

<Context path="/moskitodemo" docBase="${catalina.home}/webapps/moskitodemo"
        debug="0" >
	<Loader className=""
delegate="false" reloadable="true"/>

my loader:

public class MoskitoLoader implements Loader{
	private Loader tomcatLoader;

	public MoskitoLoader(ClassLoader classLoader){
		System.out.println("MINIT: "+classLoader);
		tomcatLoader = new WebappLoader(classLoader);

I'm proxying the calls to the WebappLoader like this:

	public ClassLoader getClassLoader() {
		ClassLoader ret = tomcatLoader.getClassLoader();
		return ret;

However, loading of the application doesn't work. The getClassLoader
method returns null and I have multiple errors in the logfile starting
SEVERE: Error deploying configuration descriptor moskitodemo.xml
        at java.util.Hashtable.put(
        at org.apache.naming.ContextBindings.bindClassLoader(
        at org.apache.catalina.core.NamingContextListener.lifecycleEvent(
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(
        at org.apache.catalina.core.StandardContext.start(
        at org.apache.catalina.core.ContainerBase.addChildInternal(
        at org.apache.catalina.core.ContainerBase.addChild(
        at org.apache.catalina.core.StandardHost.addChild(
        at org.apache.catalina.startup.HostConfig.deployDescriptor(
        at org.apache.catalina.startup.HostConfig.deployDescriptors(
        at org.apache.catalina.startup.HostConfig.deployApps(
        at org.apache.catalina.startup.HostConfig.start(
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(
        at org.apache.catalina.core.ContainerBase.start(
        at org.apache.catalina.core.StandardHost.start(
        at org.apache.catalina.core.ContainerBase.start(
        at org.apache.catalina.core.StandardEngine.start(
        at org.apache.catalina.core.StandardService.start(
        at org.apache.catalina.core.StandardServer.start(
        at org.apache.catalina.startup.Catalina.start(
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(
        at java.lang.reflect.Method.invoke(
        at org.apache.catalina.startup.Bootstrap.start(
        at org.apache.catalina.startup.Bootstrap.main(

I suppose I have to do some more than just instantiate a WebappLoader,
but where can I find what? Any points to docs?

Or do I have to implement all the Lifecycle and proxy it to the WebappLoader?


P.S. I was trying to do this from the docs without looking into the
sourcecode, if this is a wrong approach please tell :;-)

To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message