Re: Problem in JasperLoader ?

2001-08-08 Thread Serge Huber


Ok thanks a lot.

Yes I did miss the commit message (I have them filtered to another folder) 
! Thanks a lot for the quick fix !

Best greetings,
 Serge Huber...

At 09:25 08.08.2001 -0700, you wrote:
>2 is the only correct one, since if you forward to a servlet, it wouldn't
>work otherwise.
>The fix is already in the CVS (you missed the commit message apparently).
>
>I have a test case which I didn't add because it requires modifications to
>the tester.
>
>Remy




Re: Problem in JasperLoader ?

2001-08-08 Thread Serge Huber


I'd be willing to help with this issue, but from my point of view there are 
two possibilities :

1. We revert the JasperLoader changes back to parent.loadClass(name) call.

2. We modify Catalina to set the contextClassLoader during an include or a 
forward call.

I still wonder which is the best approach, but I must say I don't quite 
understand why we have to store the class loader in the Thread. It seems a 
tad ugly to do it that way...

Best greetings,
 Serge...

At 13:53 07.08.2001 -0700, you wrote:
>Quoting Serge Huber <[EMAIL PROTECTED]>:
>
> > Hi all,
> >
> > I am using a RequestDispatcher to do a cross context include to a JSP.
> > The
> > problem is there seems to be a problem in the JasperLoader
> > implementation.
> > Let me explain quickly the configuration :
> >
> > contextA :
> > - does a
> > 
> getContext("/contextB").getRequestDispatcher("path/file.jsp").include(request,
> >
> > response) call
>
>I just checked and cross-context includes and forwards have a problem.
>You can use a redirect as a workaround with b6.
>
>Remy




Problem in JasperLoader ?

2001-08-07 Thread Serge Huber


Hi all,

I am using a RequestDispatcher to do a cross context include to a JSP. The 
problem is there seems to be a problem in the JasperLoader implementation. 
Let me explain quickly the configuration :

contextA :
- does a 
getContext("/contextB").getRequestDispatcher("path/file.jsp").include(request, 
response) call

contextB :
- contains the path/file.jsp file that contains an @page 
import="com.xo3.MyClass" and of course uses the MyClass class...
- contains the WEB-INF/classes/com/xo3/MyClass

When the dispatch occurs, the JSP file is compiled and executed, but it 
complains that it can't load the MyClass class. I suspect the following 
lines in src\jasper\src\share\org\apache\jasper\servlet\JasperLoader.java :

// Class is in a package, delegate to thread context class loader
if( !name.startsWith(Constants.JSP_PACKAGE_NAME) ) {
 ClassLoader classLoader = null;
if (System.getSecurityManager() != null) {
  classLoader = 
(ClassLoader)AccessController.doPrivileged(privLoadClass);
 } else {
classLoader = 
Thread.currentThread().getContextClassLoader(); 
<
 }
 clazz = classLoader.loadClass(name);
if( resolve )
resolveClass(clazz);
return clazz;
}

The problem here is that from what I understand from the source the current 
thread context class loader is never changed from contextA to contextB. So 
that when JasperLoader executes in contextB, it actually tries to load 
classes using the class loader of contextA.

Did I miss something in configuration or is this a bug ?

Best greetings,
Serge Huber.
[EMAIL PROTECTED]




Re: Cross context class loader bug ?

2001-04-26 Thread Serge Huber


Another point I forgot to say is that I tried forcing initial load by 
setting the webraptor web application servlet to load on startup. Then 
during the dispatch process, as soon as the called web application accesses 
ANOTHER of it's classes that hasn't been loaded yet I get exactly the same 
error.

greetings,

 Serge...

At 20:52 26.04.2001 -0700, you wrote:
>Yep, that definitely looks like a bug.  Any proposed patch would
>*definitely* be welcome.
>
>Craig
>
>
>On Fri, 27 Apr 2001, Serge Huber wrote:
>
> >
> > 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 :
> >
> >  
> >  
> >
> > This is of course in a  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.
> >
> >




Re: Cross context class loader bug ?

2001-04-26 Thread Serge Huber


I understand that the patch would be welcome :) But I must say that it's 
definitely not easy to get down into the class loading code of Tomcat.

My gut feeling about this bug is that somehow the class loader isn't the 
right one once the dispatching process starts. In my example it seems like 
the class loader in effet during the dispatch is still the /caller one when 
it should be the /webraptor one. This would explain why it doesn't work 
when dispatching and fine when calling directly...

 Serge...


At 20:52 26.04.2001 -0700, you wrote:
>Yep, that definitely looks like a bug.  Any proposed patch would
>*definitely* be welcome.
>
>Craig
>
>
>On Fri, 27 Apr 2001, Serge Huber wrote:
>
> >
> > 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 :
> >
> >  
> >  
> >
> > This is of course in a  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.
> >
> >




Cross context class loader bug ?

2001-04-26 Thread Serge Huber


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 :

 
 

This is of course in a  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.