Hi all,
I am using cross context dispatching in one of my web applications. In
order to do this I have the following setup in my server.xml file :
<DefaultContext crossContext="true" reloadable="true" debug="999">
</DefaultContext>
This is of course in a <Host> tag. I know this is a little extreme to put
the cross context in the default context but well the problem is not here :)
Basically my code does the following :
ServletContext dispatchContext = request.getContext(contextNameWithSlash);
RequestDispatcher dispatcher =
dispatchContext.getNamedDispatcher(servletName);
dispatcher.include(requestWrapper, responseWrapper);
As far as I can tell from the public draft of the Servlet API 2.3 this
should be valid and no null value is returned by the functions (if I
deactivate the crossContext I get the expected behavior in getContext).
I have two webapps in my setup :
/caller
/webraptor which is the web app I want to dispatch to
Now the problem. When the above code execute, this is the stack trace I get :
2001-04-27 05:11:08 StandardWrapper[/webraptor:WebRaptor]: Marking servlet
WebRaptor as unavailable
2001-04-27 05:11:08 ApplicationDispatcher[/webraptor] Allocate exception
for servlet WebRaptor
javax.servlet.ServletException: Wrapper cannot find servlet class
com.xo3.webraptor.MainServlet or a class it depends on
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:786)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:594)
at
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:513)
at
org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:414)
at
org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:378)
...my stuff
----- Root Cause -----
java.lang.ClassNotFoundException: com.xo3.webraptor.MainServlet
at
org.apache.catalina.loader.StandardClassLoader.loadClass(StandardClassLoader.java:1064)
at
org.apache.catalina.loader.StandardClassLoader.loadClass(StandardClassLoader.java:929)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:781)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:594)
at
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:513)
at
org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:414)
at
org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:378)
... my stuff
Seems to be a problem with the class loader code when doing dispatching,
because if I call the destination servlet directly I do not get the same
behaviour and the servlet is loaded and executed correctly. The code for
the webapps is all in its right place since calling the servlet manually
works fine.
I have been scratching my head over this one for a while now and I would
appreciate any pointer. For information, I can reproduce the problem on
both tomcat4.0b3, tomcat4.0b4-dev-20010426 (the latest nightly snapshot I
could get my hands on).
Last but not least I must say that this worked fine under tomcat4.0b1 and
that I am willing to patch tomcat code if needed.
Thanks a lot,
Serge Huber.