[Jersey] Re: Jersey CD and Root Resource

From: Pavel Bucek <>
Date: Tue, 14 Feb 2012 18:23:21 +0100


you are right.

And to answer your second question: only resources annotated with [*]
will be instantiated by CDI (or more precisely - instantiation will be
deferred to CDI runtime), others will be treated like standard Resources
(so you won't be able to inject any CDI provided injectables).

Scope is defined as:

        ApplicationScoped ~ Singleton
        RequestScoped ~ PerRequest
        Dependent ~ PerRequest

ad Jersey-883: send your thanks to George Sapountzis
<> :)


import javax.annotation.ManagedBean;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.context.Dependent;
import javax.enterprise.context.RequestScoped;

On 2/10/12 9:35 AM, Martin Eigenbrodt wrote:
> Hi all,
> It appears to me from trying and looking at the source that the Jersey CDI Integration (via CDIComponentProviderFactory) will not automatically discover Root Resources (That is CDI Beans with a @Path on Class level) like the SPring Integration does. Is that right?
> So if I manual add this resource to jersey (via an Custom Application or settings the packages to be scanned) what will the lifecycle of those Resource be like? Are they instantiated by Jersey or cdi?
> By the way I'm happy to see the patch for Jersey-883 is now in the trunk. Caused me some trouble to find out this was the problem when using tomcat :-).
> Regards,
> Martin