xiaodududu / google-guice

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

ServeltContext#getRequestDispatcher cannot forward to Guice Servlets #621

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Here is the simplest test case (I'm using tomcat 5.5.33):

* Use Guice ServletModule to configure two servlets, one of which just 
dispatches to the other:

    protected void configureServlets()
    {
        serve( "/dispatcher" ).with( DispatcherServlet.class );
        serve( "/dispatchee" ).with( DispatcheeServlet.class );
    }

* Dispatchee outputs text for verification, dispatcher redirects like this:

        protected void doGet( HttpServletRequest req, HttpServletResponse resp )
            throws ServletException, IOException
        {
            this.getServletContext().getRequestDispatcher( "/dispatchee" )
                .forward( req, resp );
        }

* Invoking /dispatcher yields a blank page with a 404 status that is 
incorrectly served up by Tomcat's default servlet.

* When configuring via traditional web.xml instead of guice, everything works 
as expected.

* I did some debugging and it looks like Tomcat's internal pattern matching 
inside its RequestDispatcher implementation isn't even aware of the servlet 
mapping that Guice configured.

To fix it sounds like Guice will have to wrap the RequestDispatcher object 
returned from ServletContext to route requests appropriately (see discussion on 
issue 372).

Original issue reported on code.google.com by ori.schw...@gmail.com on 5 Apr 2011 at 4:55

Attachments:

GoogleCodeExporter commented 9 years ago
Is this the same as issue 372, or a different issue?

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

GoogleCodeExporter commented 9 years ago
sberlin, it's a different issue. I initially posted on that thread and was 
after some discussion we decided this is a separate issue. See comment 13 on 
issue 372:

http://code.google.com/p/google-guice/issues/detail?id=372#c13

Original comment by ori.schw...@gmail.com on 16 Oct 2011 at 5:01