0 Replies Latest reply on May 23, 2011 5:30 AM by Hans Stöber

    Managed beans, Weld client proxy, custom annotations

    Hans Stöber Newbie


      I am using Glassfish 3.1 with included Weld 1.1.0 final and Jersey 1.5. I defined a simple Jersey resource class and a managed bean, both annotated with @Model. I am injecting the managed bean into the Jersey resource class, which works fine. Apart from @Model, the managed bean is also annotated with some custom annotation, retention is RetentionPolicy.RUNTIME.

      Here is some simplistic code to demonstrate what I'm doing:

      Managed Bean:

      public class MyManagedBean {
           public MyManagedBean() {
                // intentionally left blank

      Resource class:

      public class MyResource {
           private MyManagedBean myManagedBean;
           public String display() {
                return  Arrays.toString(myManagedBean.getClass().getAnnotations());


      public @interface MyAnnotation {

      However, it seems that the generated Weld client proxy for the managed bean does not include the annotations. For example, if I do a


      an empty array is returned. This does not seem to be limited to custom annotations, since also the @Model annotation is missing.

      The only way I found to access the annotatons is to cast the managed bean to TargetInstanceProxy, and call getTargetClass() like that:


      Obviously this is nothing I want in my code. So, my question is:

      • are the annotations removed on purpose? Why?

      • is there any way to access them without using none-portable JBoss code / classes?