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

JAX-RS name binding annotation on Application hidden by Weld proxy

    XMLWordPrintable

Details

    • Hide
      1. Create a JAX-RS name binding annotation, application and filter, as above.
      2. Add a resource class and method (POJO with a method returning a String) both annotated with @Path("/something")).
      3. Deploy under WildFly, verify that /xxx/something/something works as expected and that the filter methods get invoked before and after the resource handler. Also verify that the filter's application field is set to a ServiceApplication instance and that you can retrieve the 2 annotations on it.
      4. Stop WildFly, activate Weld, deploy the exact same application again.
      5. Verify that /xxx/something/something works as before, but the filter is no longer invoked.
      6. Annotate the resource class with @Monitored and redeploy the app.
      7. Verify that /xxx/something/something works again, the filter is now being invoked again, but its application field points to a Weld proxy instead of directly to a ServiceApplication instance and that the proxy has no annotations (neither @Monitored nor @ApplicationPath).
      Show
      Create a JAX-RS name binding annotation, application and filter, as above. Add a resource class and method (POJO with a method returning a String ) both annotated with @Path("/something") ). Deploy under WildFly, verify that /xxx/something/something works as expected and that the filter methods get invoked before and after the resource handler. Also verify that the filter's application field is set to a ServiceApplication instance and that you can retrieve the 2 annotations on it. Stop WildFly, activate Weld, deploy the exact same application again. Verify that /xxx/something/something works as before, but the filter is no longer invoked. Annotate the resource class with @Monitored and redeploy the app. Verify that /xxx/something/something works again, the filter is now being invoked again, but its application field points to a Weld proxy instead of directly to a ServiceApplication instance and that the proxy has no annotations (neither @Monitored nor @ApplicationPath ).

    Description

      I have a JAX-RS application declaring an empty Application subclass with only a couple of annotations: @ApplicationPath and @Monitored (self-defined name binding annotation).

      @ApplicationPath("/xxx")
      @Monitored  // My custom JAX-RS name binding annotation
      public class ServiceApplication extends Application {}
      

      For reference, this is the definition of the @Monitored annotation:

      @Target({ ElementType.TYPE, ElementType.METHOD })
      @Retention(value = RetentionPolicy.RUNTIME)
      @NameBinding
      public @interface Monitored {}
      

      I am also applying the @Monitored annotation to a JAX-RS request/response filter:

      @Provider
      @Monitored
      public class MonitoringFilter
          implements ContainerRequestFilter, ContainerResponseFilter {
      
        /** The application context, used for retrieving the {@link ApplicationPath} value. */
        @Context
        Application application;
      
        // [...]
      }
      

      Per the JAX-RS spec this should cause my filter to intercept all requests to resources belonging to ServiceApplication (which, since I'm not doing anything else, defaults to all resources defined in the webapp.

      If I run my application under WildFly without Weld, everything runs just fine. My filter intercepts all requests and its application field points to an instance of ServiceApplication. As soon as I activate Weld a couple of things happen:

      1. My filter stops working. I can make it work again by applying the @Monitored annotation to each and every resource class, and then I see:
      2. The application field of the filter gets set to a Weld proxy of ServiceApplication and this proxy is missing both the @ApplicationPath and @Monitored annotations. The requests still get routed properly (e.g. if my resource is annotated with @Path("/yyy") then I have to use /xxx/yyy to get to it) but I cannot reconstruct that path by looking at the annotations of the application and the resource.

      Attachments

        Activity

          People

            rsigal@redhat.com Ronald Sigal
            alin.sinpalean Alin Sinpalean (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: