google / guice

Guice (pronounced 'juice') is a lightweight dependency injection framework for Java 11 and above, brought to you by Google.
https://github.com/google/guice
Apache License 2.0
12.48k stars 1.67k forks source link

ServeltContext#getRequestDispatcher cannot forward to Guice Servlets #621

Open gissuebot opened 10 years ago

gissuebot commented 10 years ago

From ori.schwartz on April 05, 2011 12:55:31

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 ).

Attachment: gist    GuiceRequestDispatcherBug.java

Original issue: http://code.google.com/p/google-guice/issues/detail?id=621

gissuebot commented 10 years ago

From sberlin on October 16, 2011 09:34:02

Is this the same as issue 372 , or a different issue?

gissuebot commented 10 years ago

From ori.schwartz on October 16, 2011 10:01:34

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 : https://code.google.com/p/google-guice/issues/detail?id=372#c13