xiaodududu / google-guice

Automatically exported from code.google.com/p/google-guice
Apache License 2.0
0 stars 0 forks source link

Provider<ServletRequest> does not provide a wrapped servlet request capable of executing RequestDispatcher.include #584

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I am using Guice 2.0 (Maven artifact) and Tomcat 6.x / 7.x on Ubuntu.

When I try to inject a ServletRequest with a provider (and I suspect even 
directly), the object provided is not of type ManagedFilterPipeline$2, which I 
believe is the type provided to the service(HttpServletRequest, 
HttpServletResponse) methods of guice managed servlets and required for the 
include and forward methods to work. As a result, the 
getRequestDispatcher(String) method does not return a dispatcher that is aware 
of the guice managed servlets and my include calls fail to resolve the 
appropriate servlets.

example:

Module.class
    serve("/dwr/*").with(DwrServlet.class);

SomeServlet.class
    protected void service(HttpServletRequest req, HttpServletResponse resp) {
        // Works as expected
        req.getRequestDispatcher("/dwr/engine.js").include(req, resp);
    }

SomeBrokenUtility.class
    class SomeBrokenUtility {
        @Inject Provider<ServletRequest> requestProvider;

        public String pullFromDwr() {
            FakeHttpResponse resp = ...;

            ServletRequest req = requestProvider.get();

            // Throws a FileNotFoundException as the DefaultServlet cannot
            // locate the requested resource
            req.getRequestDispatcher("/dwr/engine.js").include(req, resp);

            return resp.getResponseAsString();
        }
    }

Original issue reported on code.google.com by steve.sk...@gmail.com on 6 Jan 2011 at 12:10

GoogleCodeExporter commented 9 years ago

Original comment by sberlin on 22 Feb 2011 at 1:45

GoogleCodeExporter commented 9 years ago
Is this the same as the problem described in issue 372?

Original comment by sberlin on 16 Oct 2011 at 4:42

GoogleCodeExporter commented 9 years ago
Possibly, but I am not certain. I think fixing this would be easier, and may 
also fix the other issue :D

Original comment by steve.sk...@gmail.com on 6 Jan 2012 at 9:19