I'm testing dropwizard 2.0 and found out that the current version of Jersey 
does not support @Context injection when registering resources as object. 
It worked in the version included in Dropwizard 1.3.9.

I think the Jersey bug is: 
https://github.com/eclipse-ee4j/jersey/issues/3438

Example resource:
@Path("/")
public class MyResource {
  @Context
  private HttpServletRequest httpServletRequest;
  ...
}

Registering as object

env.jersey().register(new MyResource());

the httpServletRequest will be null.

A workaround is to register the resource by class:

env.jersey().register(MyResource.class);

But it can be very cumbersome if the resource must be passed some 
parameters in the constructor (we need to inject them too, or pass them is 
some other way).

So I would like to know if someone found a more convenient way to manage 
this problem until it is (hopefully) fixed upstream.

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"dropwizard-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dropwizard-user/3c8e841b-891d-42b8-8dd7-d09124669502%40googlegroups.com.

Reply via email to