tomcat-users mailing list archives

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

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="net.java.dev.moskito.tomcat.MoskitoLoader"
delegate="false" reloadable="true"/>
</Context>

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
with:
SEVERE: Error deploying configuration descriptor moskitodemo.xml
java.lang.NullPointerException
        at java.util.Hashtable.put(Hashtable.java:401)
        at org.apache.naming.ContextBindings.bindClassLoader(ContextBindings.java:265)
        at org.apache.catalina.core.NamingContextListener.lifecycleEvent(NamingContextListener.java:232)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4118)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
        at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:608)
        at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:535)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:470)
        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1112)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:310)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1021)
        at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013)
        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
        at org.apache.catalina.core.StandardService.start(StandardService.java:450)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:709)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:551)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:275)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)

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?

regards
Leon

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: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message