Quantcast

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

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

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

Christopher Piggott
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Resources only available if I add a trailing slash - Jersey-Guice-Tomcat configuration

Christopher Piggott
I changed it from serve("*").with(GuiceContainer.class) to
filter("/*")..through(GuiceContainer.class)  and now it works.  Should
that have fixed it?



On Sat, May 5, 2012 at 10:49 PM, Christopher Piggott <[hidden email]> wrote:

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