<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.0.4630.0">
<TITLE>Re: OpenCMS and JBoss/Jetty</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->
<P><FONT SIZE=2 FACE="Courier New">All,</FONT>
</P>
<P><FONT SIZE=2 FACE="Courier New">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.</FONT></P>
<P><FONT SIZE=2 FACE="Courier New">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.</FONT></P>
<P><FONT SIZE=2 FACE="Courier New">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.</FONT></P>
<P><FONT SIZE=2 FACE="Courier New">The same problem occurs in your nav_demo.jsp.</FONT>
</P>
<P><FONT SIZE=2 FACE="Courier New">I think this should be implemented in the 5.0 release since a lot of people are using JBoss/Jetty and not just Tomcat.</FONT>
</P>
<P><FONT SIZE=2 FACE="Courier New">Sincerely,</FONT>
</P>
<P><FONT SIZE=2 FACE="Courier New">Marcus Redeker</FONT>
<BR><FONT SIZE=2 FACE="Courier New">Senior Java Enterprise Consultant</FONT>
<BR><FONT SIZE=2 FACE="Courier New">Gedoplan GmbH</FONT>
<BR><FONT SIZE=2 FACE="Courier New">Bielefeld, Germany</FONT>
</P>
<BR>
<BR>
<BR>
<BR>
<P><FONT SIZE=2 FACE="Courier New">-----Original Message-----</FONT>
<BR><FONT SIZE=2 FACE="Courier New">From: Greg Wilkins [</FONT><A HREF="mailto:gregw@mortbay.com"><U><FONT COLOR="#0000FF" SIZE=2 FACE="Courier New">mailto:gregw@mortbay.com</FONT></U></A><FONT SIZE=2 FACE="Courier New">] </FONT>
<BR><FONT SIZE=2 FACE="Courier New">Sent: Thursday, March 20, 2003 10:14 AM</FONT>
<BR><FONT SIZE=2 FACE="Courier New">To: Marcus Redeker</FONT>
<BR><FONT SIZE=2 FACE="Courier New">Subject: Re: Jetty Problem</FONT>
</P>
<BR>
<BR>
<P><FONT SIZE=2 FACE="Courier New">Hi Marcus,</FONT>
</P>
<P><FONT SIZE=2 FACE="Courier New">Jetty does use request wrapping for it's Dispatcher - while Tomcat does not. Both are legal within the servlet spec.</FONT>
</P>
<P><FONT SIZE=2 FACE="Courier New">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).</FONT></P>
<P><FONT SIZE=2 FACE="Courier New">However, you can rely on one of the following techniques to communicate from a servlet to the servlet it dispatches to:</FONT>
</P>
<P><FONT SIZE=2 FACE="Courier New"> + Use thread locals as the thread for a dispatch will be the same.</FONT>
</P>
<P><FONT SIZE=2 FACE="Courier New"> + Use request attributes - you could even set the CmsFlexRequest instance</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> as a specific attribute.</FONT>
</P>
<P><FONT SIZE=2 FACE="Courier New"> + The code that looks for a CmsFlexRequest can peel back the wrappers</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> one by one looking for their request object (which must be one of the</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> wrapped requests).</FONT>
</P>
<P><FONT SIZE=2 FACE="Courier New">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.</FONT></P>
<P><FONT SIZE=2 FACE="Courier New">cheers</FONT>
</P>
<BR>
<P><FONT SIZE=2 FACE="Courier New">Marcus Redeker wrote:</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> Hi Greg,</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> my name is Marcus Redeker and we met last November on the JBoss </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> training in Geneva. I am currently working with OpenCMS which is a </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> Java based content management system running on Tomcat. I try to get </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> that running on JBoss-Jetty and have a really bad problem. The peopel </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> who programmed OpenCMS are using their own ServletWrapper and </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> ServletDispatcher and all this "pretty" stuff and that is where the </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> problem starts. In their JSP-Tags they use the following lines of </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> code:</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> ========= snip =============</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> public int doEndTag() throws JspException</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> {</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> javax.servlet.ServletRequest req = pageContext.getRequest();</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> javax.servlet.ServletResponse res = pageContext.getResponse();</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> // This will always be true if the page is called through OpenCms</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> if ((req instanceof com.opencms.flex.cache.CmsFlexRequest) && (res</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> instanceof com.opencms.flex.cache.CmsFlexResponse))</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> {</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> com.opencms.flex.cache.CmsFlexRequest c_req =</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> (com.opencms.flex.cache.CmsFlexRequest)req;</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> com.opencms.flex.cache.CmsFlexResponse c_res = </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> (com.opencms.flex.cache.CmsFlexResponse)res; </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> …..</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> ======= snip ============</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> Can you see the problem? I debugged the whole scenario and saw that</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> "javax.servlet.ServletRequest req = pageContext.getRequest();" returns </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> a "org.mortbay.jetty.servlet.Dispatcher.DispatcherRequest" and not the </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> expected "com.opencms.flex.cache.CmsFlexRequest". In the debugger I </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> can see that your Dispatcher.DispatcherRequest is a wrapper around the </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> class which is expected by OpenCMS. But I cannot retrieve it!!</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> Since OpenCMS is running on Tomcat it seems that Tomcat is not</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> performing the wrapping and delivers the original request class.</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> Thanks a lot,</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> --Marcus</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> </FONT>
</P>
<BR>
<P><FONT SIZE=2 FACE="Courier New">-- </FONT>
<BR><FONT SIZE=2 FACE="Courier New">Greg Wilkins<gregw@mortbay.com> Phone/fax: +44 7092063462</FONT>
<BR><FONT SIZE=2 FACE="Courier New">Mort Bay Consulting Australia and UK. </FONT><A HREF="http://www.mortbay.com"><U><FONT COLOR="#0000FF" SIZE=2 FACE="Courier New">http://www.mortbay.com</FONT></U></A>
</P>
<BR>
<BR>
</BODY>
</HTML>