Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-745

ServletRequest/Repsonse have custom wrappers preventing them from being passed to RequestDispatcher

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • Major
    • None
    • None
    • None
    • None

    Description

      When you use @Context HttpServletRequest/HttpServletResponse, RESTEasy uses it's own wrapper classes implementing the interface rather than the javax.servlet.http ones.

      This means that you cannot pass then to RequestDispatcher.forward(), because the Servlet specification says that you must pass the original request/response or javax.servlet.http.HttpServlet

      {Request,Response}

      Wrapper objects that are chained from the original ones.

      If you deploy a JAX-RS application containing the following code, it will fail:
      @Context private ServletContext ctx;

      @GET
      @Path("/")
      public void fizzle(@Context HttpServletRequest req, @Context HttpServletResponse res) throws IOException, ServletException

      { ctx.getRequestDispatcher("fozzle").forward(req, res); }

      On AS7, it will produce an error like:

      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.apache.catalina.core.ApplicationDispatcher.checkSameObjects(ApplicationDispatcher.java:1146) [jbossweb-7.0.16.Final-redhat-1.jar:]
      at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:512) [jbossweb-7.0.16.Final-redhat-1.jar:]
      at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:488) [jbossweb-7.0.16.Final-redhat-1.jar:]
      at example.RestService.fizzle(MockResource.java:36) [classes:]
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.6.0_23]
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [rt.jar:1.6.0_23]
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [rt.jar:1.6.0_23]
      at java.lang.reflect.Method.invoke(Method.java:597) [rt.jar:1.6.0_23]
      at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:167) [resteasy-jaxrs-2.3.3.Final-redhat-1.jar:2.3.3.Final-redhat-1]
      at org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:257) [resteasy-jaxrs-2.3.3.Final-redhat-1.jar:2.3.3.Final-redhat-1]
      at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:222) [resteasy-jaxrs-2.3.3.Final-redhat-1.jar:2.3.3.Final-redhat-1]
      at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:211) [resteasy-jaxrs-2.3.3.Final-redhat-1.jar:2.3.3.Final-redhat-1]
      at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:525) [resteasy-jaxrs-2.3.3.Final-redhat-1.jar:2.3.3.Final-redhat-1]

      Attachments

        Activity

          People

            patriot1burke@gmail.com Bill Burke (Inactive)
            rhn-support-jlivings James Livingston (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: