[opencms-dev] Re: OpenCMS and JBoss/Jetty

Marcus Redeker mredeker at web.de
Mon Mar 24 20:50:27 CET 2003


All,

I found the problem why OpenCMS 5.0RC2 does not work with JBoss/Jetty.
In the JSP-Tags provided by OpenCMS you assume that the request/response
is always of your OpenCMS Request/Response type. This assumption is not
always true. Jetty eg. is putting another Wrapper around this and your
checking and casting will not be executed.

Attached please find my Email to the main Jetty developer who explained
the problem and also mentions that for the Servlet 2.4 specs your
assumption can be dangerous.

So far I fixed the problem that I check if the request/response is a
wrapper and then run through the wrapper hierarchy until I find the
OpenCMS request/response.

The same problem occurs in your nav_demo.jsp.

I think this should be implemented in the 5.0 release since a lot of
people are using JBoss/Jetty and not just Tomcat.

Sincerely,

Marcus Redeker
Senior Java Enterprise Consultant
Gedoplan GmbH
Bielefeld, Germany





-----Original Message-----
From: Greg Wilkins [mailto:gregw at mortbay.com] 
Sent: Thursday, March 20, 2003 10:14 AM
To: Marcus Redeker
Subject: Re: Jetty Problem



Hi Marcus,

Jetty does use request wrapping for it's Dispatcher - while Tomcat does
not.  Both are legal within the servlet spec.

But applications cannot be written to expect their requests not to be
wrapped.  Filters may be invoked during a dispatch that will wrap a
request in other user supplied wrappers (2.4 feature).

However, you can rely on one of the following techniques to communicate
from a servlet to the servlet it dispatches to:

   + Use thread locals as the thread for a dispatch will be the same.

   + Use request attributes - you could even set the CmsFlexRequest
instance
     as a specific attribute.

   + The code that looks for a CmsFlexRequest can peel back the wrappers
     one by one looking for their request object (which must be one of
the
     wrapped requests).

So I can only suggest that you raise an issue with the OpenCMS project.
It is only happenstance that their servlets work with Tomcat.  Once the
2.4 spec is available, their servlets will not work with dispatch
filters.

cheers


Marcus Redeker wrote:
> Hi Greg,
> 
> my name is Marcus Redeker and we met last November on the JBoss 
> training in Geneva. I am currently working with OpenCMS which is a 
> Java based content management system running on Tomcat. I try to get 
> that running on JBoss-Jetty and have a really bad problem. The peopel 
> who programmed OpenCMS are using their own ServletWrapper and 
> ServletDispatcher and all this "pretty" stuff and that is where the 
> problem starts. In their JSP-Tags they use the following lines of 
> code:
> 
> 
> ========= snip =============
> 
> public int doEndTag() throws JspException
> {
>     javax.servlet.ServletRequest req = pageContext.getRequest();
>     javax.servlet.ServletResponse res = pageContext.getResponse();
>        
>     // This will always be true if the page is called through OpenCms
>     if ((req instanceof com.opencms.flex.cache.CmsFlexRequest) && (res
> instanceof com.opencms.flex.cache.CmsFlexResponse))
> 
>     {
>         com.opencms.flex.cache.CmsFlexRequest c_req =
> (com.opencms.flex.cache.CmsFlexRequest)req;
>         com.opencms.flex.cache.CmsFlexResponse c_res = 
> (com.opencms.flex.cache.CmsFlexResponse)res;   
> 
> ...
> 
> ======= snip ============
> 
> Can you see the problem? I debugged the whole scenario and saw that
> "javax.servlet.ServletRequest req = pageContext.getRequest();" returns

> a "org.mortbay.jetty.servlet.Dispatcher.DispatcherRequest" and not the

> expected "com.opencms.flex.cache.CmsFlexRequest". In the debugger I 
> can see that your Dispatcher.DispatcherRequest is a wrapper around the

> class which is expected by OpenCMS. But I cannot retrieve it!!
> 
> Since OpenCMS is running on Tomcat it seems that Tomcat is not
> performing the wrapping and delivers the original request class.
> 
> 
> Thanks a lot,
> 
> --Marcus
> 


-- 
Greg Wilkins<gregw at mortbay.com>             Phone/fax: +44 7092063462
Mort Bay Consulting Australia and UK.          http://www.mortbay.com



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20030324/d435ff41/attachment.htm>


More information about the opencms-dev mailing list