users@jersey.java.net

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

From: Guy Rouillier <guy.rouillier_at_gmail.com>
Date: Fri, 14 Mar 2014 12:42:21 -0400

We encountered the same issue. The simplest solution is to move your
interfaces to a different package. That was a better solution for us in
the long run anyway; we exported the interface package to a client JAR
to be used with the client proxy.

On 3/14/2014 7:04 AM, Graham Leggett wrote:
> 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
> --
>


-- 
Guy Rouillier
---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com