users@jersey.java.net

[Jersey] Resources only available if I add a trailing slash - Jersey-Guice-Tomcat configuration

From: Christopher Piggott <cpiggott_at_gmail.com>
Date: Sat, 5 May 2012 22:49:39 -0400

Hi,

With Jersey 1.12 and Tomcat 7, when I get a resoruce like this:

@Path("/something")
public class SomeResource {
  @GET
  public String someMethod() { return "hi"; }
}

when I try to do this, it only works if I

   GET /webAppRoot/something/

but NOT if I

   GET /webAppRoot/something

I have been trying to track this down. Web.xml looks like this:

        <listener>
                <listener-class>com.autofrog.live.ServletConfig</listener-class>
        </listener>

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


and the module's configureServlets() ends in:

                serve("*").with(GuiceContainer.class, params);


Any ideas on what could be going wrong here?

--Chris