users@jersey.java.net

[Jersey] Annotations in interfaces, how to use with jersey?

From: Graham Leggett <minfrin_at_sharp.fm>
Date: Fri, 14 Mar 2014 13:04:25 +0200

Hi all,

I have wadl2java generating an interface as below, and I have an implementation in the same package that implements that interface, but jersey v2.6 cannot find it:

   @GET
   @Produces("application/json")
   @Path("/browse/{mail}")
   Response retrieveUser(@PathParam("mail") String mail, @HeaderParam("If-Modified-Since") java.util.Date If_Modified_Since);

The warning I get is:

WARNING: Component of class interface xx.users.jaxrs.service.UserResource cannot be instantiated and will be ignored.

Attempts to hit the URL return 404.

I've done lots of googling for this, and it seems that all answers to this question involve "use spring" or use some other framework, when I just want to use jersey on it's own.

Does anyone know how to tell jersey to look for implementations of an interface when scanning packages on the classpath?

Jersey is configured as follows:

        <servlet>
                <servlet-name>Jersey Web Application</servlet-name>
                <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
                <init-param>
                        <param-name>jersey.config.server.provider.packages</param-name>
                        <param-value>xx.users.jaxrs.service</param-value>
                </init-param>
                <load-on-startup>1</load-on-startup>
        </servlet>

Regards,
Graham
--