[jax-rs-spec users] [jsr339-experts] Back To DI in Subresources

From: Adam Bien <>
Date: Sun, 15 Apr 2012 22:33:53 +0200


I would like to re-activate the already mentioned issue of lack of support of DI in sub-resources.

Usually you are going to separate JAX-RS resources and services into separate classes. In that case services are going to be injected into resource with @Inject (it works already fine in Java EE 6).

However: usually JAX-RS runtime is navigating from the main Resource to the sub-resource class via the @Path annotation.

As developer you are creating a sub-resource using an ordinary "new" and a constructor with parameters. The sub-resources instance is no more managed and injection is not available.

Proposal: we need a way to pass an instance to a JAX-RS runtime to inject dependencies.

Btw. parameterless constructors are not enough - usually you are going to pass some context from the main resource to the sub resources.

See also: