I am playing with Guice 2.0 and WebSphere 6.1. My servlet is
configured in Guice module.

public class ServletConfigListener extends GuiceServletContextListener
{
        @Override
        protected Injector getInjector() {
                return Guice.createInjector(new RpcServerModule());
        }
}

public class RpcServerModule extends ServletModule {
        @Override
        protected void configureServlets() {
                serve("*.rpc").with(RpcServiceImpl.class);
        }
}

And I have configured GuiceFilter and above listener in my web.xml.
        <filter>
                <filter-name>guiceFilter</filter-name>
                
<filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
        </filter>
        <filter-mapping>
                <filter-name>guiceFilter</filter-name>
                <url-pattern>/*</url-pattern>
        </filter-mapping>
        <listener>
                <listener-class>
                        gov.ontario.mnr.irs.ServletConfigListener
                </listener-class>
        </listener>

However my servlet RpcServiceImpl is never called. I traced Guice and
found out in class com.google.inject.servlet.ServletDefinition, method
service(), it tries to match the servlet path with my servlet pattern:
  public boolean service(ServletRequest servletRequest,
      ServletResponse servletResponse) throws IOException,
ServletException {
    final boolean serve = shouldServe(((HttpServletRequest)
servletRequest).getServletPath());

But the servlet path always equals to "", then the pattern is not
matched. Should Guice use request URI instead of servlet path when try
to match servlet pattern?

I worked this around by putting following lines in web.xml:
        <servlet>
                <servlet-name>RpcServlet</servlet-name>
                <display-name>Gwt-Rpc Servlet</display-name>
                <servlet-class>com.my.RpcServiceImpl</servlet-class>
        </servlet>
        <servlet-mapping>
                <servlet-name>RpcServlet</servlet-name>
                <url-pattern>*.rpc</url-pattern>
        </servlet-mapping>

I don't believe this is a Guice bug, as if it is a bug, it should be
very easy to be detected. What did I do wrong? Any help is very
appreciated. Thank you.
-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.


Reply via email to