java.lang.ClassCastException: org.zkoss.web.portlet.RenderHttpServletRequest cannot be cast to javax.servlet.ServletRequestWrapper

ZK-Tracker | jezelinside | 5 years ago
tip
Click on the to mark the solution that helps you, Samebug will learn from it.
As a community member, you’ll be rewarded for you help.
  1. 0

    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.

    ZK-Tracker | 5 years ago | jezelinside
    java.lang.ClassCastException: org.zkoss.web.portlet.RenderHttpServletRequest cannot be cast to javax.servlet.ServletRequestWrapper
  2. 0

    Liferay 6.1 + JBoss 7.1 + ZK 6 : Issue with the way RenderRequest are wrapped - ZK Forum

    zkoss.org | 11 months ago
    java.lang.ClassCastException: org.zkoss.web.portlet.RenderHttpServletRequest cannot be cast to javax.servlet.ServletRequestWrapper
  3. 0

    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.

    ZK-Tracker | 5 years ago | jezelinside
    java.lang.ClassCastException: org.zkoss.web.portlet.RenderHttpServletRequest cannot be cast to javax.servlet.ServletRequestWrapper
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Render and capture the output of a JSP as a String | Technological Oddity

    technologicaloddity.com | 11 months ago
    java.lang.ClassCastException: com.bankbjb.itcore.cashportal.common.MockIncludedHttpServletRequest cannot be cast to javax.servlet.ServletRequestWrapper

    Root Cause Analysis

    1. java.lang.ClassCastException

      org.zkoss.web.portlet.RenderHttpServletRequest cannot be cast to javax.servlet.ServletRequestWrapper

      at org.apache.catalina.core.ApplicationFilterFactory.createFilterChain()
    2. Glassfish Core
      ApplicationDispatcher.include
      1. org.apache.catalina.core.ApplicationFilterFactory.createFilterChain(ApplicationFilterFactory.java:164)
      2. org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:827)
      3. org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:720)
      4. org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:657)
      4 frames
    3. The ZKoss Web Library
      Portlets.include
      1. org.zkoss.web.portlet.ServletPortletDispatcher.include(ServletPortletDispatcher.java:51)
      2. org.zkoss.web.portlet.Portlets.include(Portlets.java:72)
      2 frames
    4. ZK Kernel
      DHtmlLayoutPortlet.doView
      1. org.zkoss.zk.ui.http.DHtmlLayoutPortlet.handleError(DHtmlLayoutPortlet.java:335)
      2. org.zkoss.zk.ui.http.DHtmlLayoutPortlet.doView(DHtmlLayoutPortlet.java:146)
      2 frames