I'm wondering if there are examples of how to work around this when the 
resource class constructor takes parameters? Does this changes mean I need 
to integrate a DI framework?

On Sunday, August 25, 2019 at 1:12:20 PM UTC-4 [email protected] wrote:

> Hi Paolo,
>
> see 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
> .
>
> 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
>
> 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/ce07832e-97e9-4a1c-a51b-71e4d789084en%40googlegroups.com.

Reply via email to