-
Bug
-
Resolution: Done
-
Major
-
7.4.7.GA
-
None
-
False
-
None
-
False
-
-
-
-
-
-
-
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; } }
import javax.ws.rs.container.ResourceInfo; @ApplicationScoped public class TestFilter implements ContainerRequestFilter { @Context HttpServletRequest request; @Context UriInfo uriInfo; @Context ResourceInfo resourceInfo; @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.
- incorporates
-
RESTEASY-3256 CDI managed beans do not inject @Context injection targets
- Resolved