users@jersey.java.net

Re: Jersey with Spring always giving 404 for subresources

From: Paul Sandoz <Paul.Sandoz_at_oracle.com>
Date: Wed, 24 Nov 2010 10:37:42 +0100

On Nov 23, 2010, at 8:14 PM, Jason Erickson wrote:

> OK, I figured out the problem - it was in my web.xml. I had
> configured several paths for servlet mapping to the Jersey Spring
> servlet, but that didn't work. What did work was:
> <servlet-mapping>
> <servlet-name>jersey-spring</servlet-name>
> <url-pattern>/</url-pattern>
> </servlet-mapping>
>
> I could not get any other mapping to work - giving me 404's on
> everything except for the explicit mapping path. Is this a bug? Or
> is there some reason why this is supposed to be the way it works?
>

I noticed you had multiple declarations of the servlet mapping for
"jersey-spring" was that intentional?

Did you replace all those mappings with the one above?

Given the way sub-resource matching works and what you say the request
for the sub-resource is not even getting through to the Jersey
runtime. You can confirm by enabling tracing and logging:

      <init-param>
          <param-
name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name>
          <param-
value>com.sun.jersey.api.container.filter.LoggingFilter</param-value>
      </init-param>
      <init-param>
          <param-
name>com.sun.jersey.spi.container.ContainerResponseFilters</param-name>
          <param-
value>com.sun.jersey.api.container.filter.LoggingFilter</param-value>
      </init-param>
      <init-param>
          <param-name>com.sun.jersey.config.feature.Trace</param-name>
          <param-value>true</param-value>
      </init-param>


I wonder if there is a bug in Jetty? can you try a test and deploy on
Tomcat?

Paul.

> On Nov 17, 2010, at 12:32 PM, Jason Erickson wrote:
>
>> One more thing: When I put a breakpoints in the getTestText() and
>> getTimelineResource() methods below and debug, a request to /
>> reports will break, but a request to /reports/testitem doesn't,
>> implying that it never enters the getTimelineResource method.
>>
>> On Nov 17, 2010, at 12:10 PM, Jason Erickson wrote:
>>
>>>> @Path("testitem")
>>>> public TestItemResource getTimelinResource() {
>>>> return timelineResource;
>>>> }
>>>>
>>>> @GET
>>>> @Produces(MediaType.TEXT_PLAIN)
>>>> public String getTestText() {
>>>> return "Success!\n";
>>>> }
>>
>