users@jersey.java.net

[Jersey] Re: Context injection in glassfish 3

From: Pavel Bucek <pavel.bucek_at_oracle.com>
Date: Tue, 03 Jul 2012 16:42:32 +0200

There are some limitation in injection, especially when you are working
with other injection frameworks. In that case, resource class instances
are NOT created by jersey and sometimes it just have no opportunity to
inject own objects.

Putting @Context UriInfo ui into resource method parameter declaration
should work for you.

Regards,
Pavel

On 6/27/12 6:11 AM, Christopher Piggott wrote:
> I am finding simple things that used to work great in a standalone
> servlet are not working so well in grizzly. I'm sure it's my fault.
>
> I can't figure out how to make context injections work:
>
> @Path("/wadl")
> @RequestScoped
> @ManagedBean
> public class Wadl {
>
> private static final Logger log = LoggerFactory.getLogger(Wadl.class);
> private byte[] wadlXmlRepresentation;
>
>
> @Context
> private UriInfo uriInfo; /* Always null */
> ...
>
> I have tried various combinations of @ManagedBean or not,
> @RequestScoped or not ... I didn't explicitly define any
> InjectableProviders for this, because I figured one would already be
> there.
>
> Essentially there's not much configuration in my hello world app.
> It's a war with a bunch of resource classes in it. The resources that
> don't need context injections work just fine.
>
>
> Shouldn't this just work?
>
>