Hi Paolo,

see https://github.com/dropwizard/dropwizard/issues/2781 
<https://github.com/dropwizard/dropwizard/issues/2781> and 
https://github.com/dropwizard/dropwizard/wiki/Upgrade-guide-1.3.x-to-2.0.x#context-injection-on-fields-in-resource-instances
 
<https://github.com/dropwizard/dropwizard/wiki/Upgrade-guide-1.3.x-to-2.0.x#context-injection-on-fields-in-resource-instances>.

Cheers,
Jochen

> Am 22.08.2019 um 16:04 schrieb Paolo Simonazzi <[email protected]>:
> 
> 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 
> <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/6B48E28E-095B-4F97-9A16-015CCA0385C4%40schalanda.name.

Reply via email to