-
Bug
-
Resolution: Done
-
Critical
-
3.15.4.Final, 5.0.4.Final, 6.2.1.Final
In a provider that is not annotated with @Provider and is a CDI managed bean, the @Context injection targets are left null. An example would be a filter that is installed via a feature.
@Provider public class FilterRegistrationFeature implements Feature { @Override public boolean configure(FeatureContext context) { context.register(TestFilter.class); return true; } }
@ApplicationScoped public class TestFilter implements ContainerRequestFilter { @Context HttpServletRequest request; @Context UriInfo uriInfo; @Inject HttpServletRequest injectedRequest; @Inject TestBean testBean; public void filter(ContainerRequestContext requestContext) { System.out.println("request " + request); System.out.println("injectedRequest " + injectedRequest); System.out.println("uriInfo " + uriInfo); System.out.println("testBean " + testBean); } }
In this case the request and uriInfo are both null. In RESTEasy 6.1+ you can just @Inject these types. However, with 5.x and lower that is not possible. The JavaDoc for Configurable.register(Class) indicates:
As opposed to component instances registered via register(Object) method, the lifecycle of components registered using this class-based register(...) method is fully managed by the JAX-RS implementation or any underlying IoC container supported by the implementation.
- is incorporated by
-
JBEAP-24194 [GSS](7.4.z) RESTEASY-3256 - CDI managed beans do not inject @Context injection targets
- Closed
-
WFLY-17404 Upgrade RESTEasy to 6.2.2.Final
- Closed