users@jersey.java.net

Re: [Jersey] Re: roll-your-own Guice

From: Christopher Piggott <cpiggott_at_gmail.com>
Date: Fri, 3 Jul 2009 14:43:18 -0400

I think I'm 90% of the way there.

I made my test resource a singleton, like this

@Path("/test")
@Singleton
public class TestResource {
    static Logger log = LogManager.getLogger(TestResource.class);
    @Inject
    public TestResource()
    {
        log.info("Created a TestResource");
    }

    @GET
    @Produces("text/plain")
    @Inject
    public String getIt() {
        return "Hello From Guice";
    }
}


I configure it like this:

public class JerseyGuiceModule extends ServletModule {
    ...
    @Override
    protected void configureServlets() {
        log.info("Configuring servlets");
        bind(TestResource.class);
        bind(CacheResource.class);
        serve("/*").with(GuiceContainer.class);
        log.info("Done configuring servlets");
    }
}


I see the log message indicating that TestResource was created, but
the jersey registration doesn't work. My webapp's root is /alarm so I
expect I should find this test resource at /alarm/test or /alarm/test/
but the server just returns a 404, as if the registration didn't take
place.

Is there some way I can probe jersey to see what paths/resources it
thinks are registered?