title: Annotation not found on object with Runtime retention
body: <p>Ok, I'm a little bit confused here. I'm trying to select a "DAO" class by using an annotation on the model:</p>
  
  <pre><code>@Entity
  @Table(name="dispatcher")
  // use the Kamailio Base DAO for code that supports this annotation
  @DAOSelector(dao = DAOBaseKamailio.class) 
  public class DispatcherSet extends Model {
      [...]
  }
  </code></pre>
  
  <p>Here is the annotation defenition:</p>
  
  <pre><code>@Target({ElementType.TYPE})
  @Retention(RetentionPolicy.RUNTIME)
  @Documented
  public @interface DAOSelector {
         Class&lt;?&gt; dao();
  }
  </code></pre>
  
  <p>I use the following code to return the proper "DAO" class:</p>
  
  <pre><code>public static DAOInterface getCorrectDAO(final Object object) throws Exception {
    final DAOSelector annotation = 
      object.getClass().getAnnotation(DAOSelector.class);
  
    if(annotation != null) {
      System.out.println("Annotation present: " + 
        annotation.dao().getName() + " for class " + object.getClass().getName());
  
      final Object dao = annotation.dao().newInstance();
      if(!(dao instanceof DAOInterface)) {
        throw new Exception("Invalid Base DAO in annotation for entity " + 
          object.getClass().getName());
      }
      return (DAOInterface) dao;
    }
    else {
      System.out.println("Annotation not present for class " + 
        object.getClass().getName());
      return new DAOBase();
    }
  }
  </code></pre>
  
  <p>However, when I feed a <code>DispatcherSet</code> object annotation is always null:</p>
  
  <blockquote>
    <p>10:33:38,498 [INFO] [STDOUT] Annotation not present for class model.DispatcherSet</p>
  </blockquote>
  
  <p>Am I missing something here?</p>
  
  <p>edit:</p>
  
  <p>OK, found something interesting, I'm running this code inside a JBoss container and when I print out all the annotations:</p>
  
  <pre><code>{{{
  $Proxy76
  $Proxy708
  $Proxy77
  }}}
  </code></pre>
  
  <p>One of these should be a proxied instance of the <code>DAOSelector</code> annotation I'm guessing, so that's probably why <code>getAnnotation(DAOSelector.class)</code> won't work, checking it out.</p>
  
  <p>edit2: </p>
  
  <p>Nope, they are not an instance of <code>DAOSelector</code></p>