users@jersey.java.net

Re: [Jersey] Injection question - Guice + HttpServletRequest

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 07 Oct 2009 22:23:54 +0200

On Oct 7, 2009, at 8:33 PM, Marc Hadley wrote:

> On Oct 7, 2009, at 2:06 PM, DirkM wrote:
>>
>> Marc Hadley wrote:
>>>
>>> You can still get the HttpHeaders as a field:
>>> @Context HttpHeaders headers;
>>>
>>
>> I tried that but it gave me a NullPointerException when I tried to
>> access
>> it.

 From where did you access it from? It would of course be null if you
accessed it from the constructor.

BTW ContainerRequest implements HttpHeaders. So i probably think you
do not require this to be injected.


>> I was under the impression you can only use @Context in certain
>> situations, such as within a Resource class...
>>
> Right, sorry I thought it was a resource class. My mistake.
>

Hmm,,, but it is a provider because it implements the
ResourceFilterFactory interface so injection Jersey/JAX-RS artifacts
should occur.

It could be a bug but i would need to know more about when the field
was accessed and the binding of the class.

Paul.