Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-2652

Context injection fails on sub resource locators

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • 4.5.2.Final
    • jaxrs
    • None

      While working on integrating RESTEasy into OpenLiberty, I found a test case that seems to fail for me - it involves `@Context` injection into a sub resource locator class.  For example:
      @Path("/hello")
      public class HelloController {
        @Context
        ResourceContext resouceContext;
       
        @Path("/init")
        public SubResource initResource() {
          return resouceContext.initResource(newSubResource());
      {{  }}}

        @Path("/get")
        public SubResource getResource() {
          return resouceContext.getResource(SubResource.class);
      {{  }}}
      }

       
      public class SubResource {
        @Context
        UriInfo uriInfo;
       
        @GET
        public String checkContextInjection() {
          return uriInfo == null ? "Failed" : "Worked";
      {{  }}}
      }

       
      In my local Open Liberty workspace, the first sub-resource method (initResource) works, but the second (getResource) fails - the injection of the UriInfo object does not occur.
       
      I created a reproducer app that runs on Wildfly 20.0.1, and in that app, both methods fail (uriInfo is null).  I'm not sure what version of RESTEasy is included in 20.0.1.
       
      My reproducer app is available at:
      https://github.com/andymc12/subresource-issue

              Unassigned Unassigned
              andymc12 Andy McCright (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated: