users@jersey.java.net

[Jersey] Re: Missing dependency for field when trying to inject a custom context with a Jersey

From: <marek.potociar_at_oracle.com>
Date: Mon, 12 Dec 2011 12:59:59 +0000 (GMT)

JAX-RS specification does not mandate the behavior provided by Apache
Wink. IOW, the feature you are trying to use that works on Apache Wink
makes your code non-portable.

To produce 100% JAX-RS portable code, you need to inject
javax.ws.rs.ext.Providers instance and then use:

 ContextResolver<MyContext> r =
Providers.getContextResolver(MyContext.class, null);
 MyContext ctx = r.getContext(MyContext.class);

to retrieve your MyContext instance.

In Jersey, you can also directly inject ContextResolver<MyContext>,
which saves you one line of code from the above, but note that this
strategy is also not 100% portable.

HTH,
Marek