Uploaded image for project: 'JBoss Enterprise Application Platform'
  1. JBoss Enterprise Application Platform
  2. JBEAP-24194

[GSS](7.4.z) RESTEASY-3256 - CDI managed beans do not inject @Context injection targets


    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 7.4.10.CR1, 7.4.10.GA
    • 7.4.7.GA
    • REST
    • None

      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.

      public class FilterRegistrationFeature implements Feature {
          public boolean configure(FeatureContext context) {
              return true;
      import javax.ws.rs.container.ResourceInfo;
      public class TestFilter implements ContainerRequestFilter {
          HttpServletRequest request;
          UriInfo uriInfo;
          ResourceInfo resourceInfo;
          HttpServletRequest injectedRequest;
          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.

            jperkins-rhn James Perkins
            rhn-support-bmaxwell Brad Maxwell
            0 Vote for this issue
            7 Start watching this issue