Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-1337

Liferay 6.1 + JBoss 7.1 + ZK 6 : RenderHttpServletRequest & RenderHttpServletResponse don't respect STRICT_SERVLET_COMPLIANCE

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 6.0.0, 6.0.1
    • Fix Version/s: 6.0.3, 6.5.1
    • Component/s: General
    • Labels:
    • Environment:

      Windows 7 64 bit, Liferay 6.1, JBoss 7.1
      Reproductible on JBoss 7.0 and Linux as well

      Description

      ZK wraps RenderRequest to org.zkoss.web.portlet.RenderHttpServletRequest and RenderResponse to org.zkoss.web.portlet.RenderHttpServletResponse, using static getInstance() methods.

      It causes exceptions that go like this :

      13:56:15,342 ERROR [com.liferay.portal.kernel.servlet.PortletServlet] (http--0.0.0.0-8080-2) javax.portlet.PortletException: javax.servlet.ServletException: Original SevletRequest or wrapped original ServletRequest not passed to RequestDispatcher in violation of SRV.8.2 and SRV.14.2.5.1: javax.portlet.PortletException: javax.servlet.ServletException: Original SevletRequest or wrapped original ServletRequest not passed to RequestDispatcher in violation of SRV.8.2 and SRV.14.2.5.1
      >> at org.zkoss.web.portlet.ServletPortletDispatcher.include(ServletPortletDispatcher.java:57) [zweb-6.0.0.jar:]
      >> at org.zkoss.web.portlet.Portlets.include(Portlets.java:72) [zweb-6.0.0.jar:]
      >> at org.zkoss.zk.ui.http.DHtmlLayoutPortlet.handleError(DHtmlLayoutPortlet.java:335) [zk-6.0.0.jar:6.0.0]
      >> at org.zkoss.zk.ui.http.DHtmlLayoutPortlet.doView(DHtmlLayoutPortlet.java:146) [zk-6.0.0.jar:6.0.0]

      JBoss & Tomcat (when using Liferay 6.1) are affected. If we try not to use strict servlet compliance (by setting system property "-Dorg.apache.catalina.STRICT_SERVLET_COMPLIANCE=false"), this leads to another exception wich is shown below :

      14:16:58,743 ERROR [portal-web.docroot.html.portal.render_portlet_jsp] (http--0.0.0.0-8080-2) java.lang.ClassCastException: org.zkoss.web.portlet.RenderHttpServletRequest cannot be cast to javax.servlet.ServletRequestWrapper
      >> at org.apache.catalina.core.ApplicationFilterFactory.createFilterChain(ApplicationFilterFactory.java:164)
      >> at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:827)
      >> at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:720)
      >> at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:657)
      >> at org.zkoss.web.portlet.ServletPortletDispatcher.include(ServletPortletDispatcher.java:51)
      >> at org.zkoss.web.portlet.Portlets.include(Portlets.java:72)
      >> at org.zkoss.zk.ui.http.DHtmlLayoutPortlet.handleError(DHtmlLayoutPortlet.java:335)
      >> at org.zkoss.zk.ui.http.DHtmlLayoutPortlet.doView(DHtmlLayoutPortlet.java:146)

      Workaround : As an alternative, I rewrote org.zkoss.web.portlet.RenderHttpServletRequest to use standard javax.servlet.http.HttpServletRequestWrapper. Here's my code :

      /**

      • A facade of RenderRequest that implements HttpServletRespose.
      • @author tomyeh
        */
        public class RenderHttpServletRequest implements HttpServletRequest {
        private final RenderRequest _req;
        private final HttpServletRequest _hreq;
        private String _enc = "UTF-8";
        private final Map<String, String> _attrs = new HashMap<String, String>(8);

      public static HttpServletRequest getInstance(RenderRequest req) {
      final HttpServletRequest res;

      if (req instanceof HttpServletRequest)

      { res = (HttpServletRequest) req; }

      else

      { res = new RenderHttpServletRequest2(req); }

      // wraps HttpServletRequest to prevent further type checks :
      return new HttpServletRequestWrapper(res);
      }

      ... code unchanged after that ...
      }

      As a better alternative, RenderHttpServletRequest & RenderHttpServletResponse should inherit from (resp.) HttpServletRequestWrapper & HttpServletResponseWrapper or at least, use such wrappers in getInstance() methods.

        Attachments

          Activity

            People

            Assignee:
            neillee neillee
            Reporter:
            jezelinside jezelinside
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: