users@jersey.java.net

[Jersey] Re: _at_Context HttpServletRequest not injected in Grizzly2 JerseyTest

From: Paul O'Fallon <paul_at_ofallonfamily.com>
Date: Wed, 29 Oct 2014 21:17:11 -0400

From the Jersey docs (
https://jersey.java.net/documentation/latest/test-framework.html#d0e15530)
it looks like Grizzly supports two Test Container Factories. You'll want
to be sure you're using the GrizzlyWebTestContainerFactory in order to get
Servlet support.

Hope this helps!

- Paul

On Wed, Oct 29, 2014 at 6:52 PM, Stevo Slavić <sslavic_at_gmail.com> wrote:

> Hello Jersey community,
>
> In ExceptionMapper implementation I have HttpServletRequest field,
> annotated with @Context. When running application in servlet container,
> field gets injected appropriately.
>
> In a resource test extending JerseyTest, with
> jersey-test-framework-provider-grizzly2 provider, exception gets thrown and
> mentioned exception mapper handles the exception. Problem is that the
> request does not get injected - it is null.
> Same exception mapper has UriInfo field, also annotated with @Context, and
> in that test it gets injected well.
>
> Am I doing something wrong? Are my expectations wrong that this should
> work? Should I enable something? Is this a bug?
>
> I'm using jersey 2.13
>
> Kind regards,
> Stevo Slavic.
>