users@jersey.java.net

[Jersey] Question about PackagesResourceConfig usage

From: NBW <emailnbw_at_gmail.com>
Date: Wed, 9 Mar 2011 14:59:04 -0500

I was trying to try out the approach of deploying my Jersey service by
extending PackagesResourceConfig as is done in Example 2.8 of the User's
Guide [1]. My class looks like this:

package com.myapp.ws.rs;

public class TestApplication extends PackagesResourceConfig {
    public TestApplication() {
        super("com.myapp.api");
    }
}

I have a Servlet 3.0 web.xml file, however, it simply contains the <web app
.. > element. I also have a 3.0 sun-web.xml which is empty right now save
for the DOCTYPE and an empty <sun-web-app> element.

My Provider resource class looks like this (some content omitted):

@Path("/foo")
@Stateless
public class FooTest {

    @EJB
    FooBean aFooBean;

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    @Path("/hw")
    public Response getHW() {
        return Response.ok("hello, world").build();
    }

....

I get a 404 when I try to access
http://localhost:8080/contextRoot/foo/hwwhere contextRoot is the cr
for my web app. This test code deploys and works
fine when I take the servlet 2.5 web.xml approach of using the Jersey
ServletContainer servlet.

Any hints as to what I am missing with this other approach? Thanks,

-Noah

[1] -
http://jersey.java.net/nonav/documentation/latest/user-guide.html#d4e194