Thank you both for your replies.
flavia, all my annotations are set to RetentionPolicy.RUNTIME. If only that was
the issue... :)
stalep, I created a unit test and it read the annotation correctly. It seems
that when I deploy it to my app server (Tomcat) the annotation can't be read.
Here's a simple class I was using to recreate the issue.
| public class Person {
| private static HashMap<Integer,Person> peopleMap = new
HashMap<Integer,Person>();
|
| @ReadLock
| public static Person getPerson(@FirmId Integer firmId) {
| try {
| Method m =
Person.class.getMethod("getPerson",Integer.class);
| Annotation[][] paramAnnot = m.getParameterAnnotations();
| for(Annotation[] a : paramAnnot) {
| System.out.println("# of Annotations Found: " +
a.length);
| //log.debug("# of Annotations Found: " +
a.length);
| }
| } catch(NoSuchMethodException e) {
| System.out.println("Method not found");
| //log.debug("No Such Method");
| }
| return peopleMap.get(firmId);
| }
|
| public static void main(String[] args) {
| try {
| Method m =
Person.class.getMethod("getPerson",Integer.class);
| Annotation[][] paramAnnot = m.getParameterAnnotations();
| for(Annotation[] a : paramAnnot) {
| System.out.println("# of Annotations Found: " +
a.length);
| //log.debug("# of Annotations Found: " +
a.length);
| }
| } catch(NoSuchMethodException e) {
| System.out.println("Method not found");
| //log.debug("No Such Method");
| }
| }
| }
|
when main is run, i get "# of Annotations Found: 1". However, when I make a
call to getPerson after it's been deployed to Tomcat, I get "# of Annotations
Found: 0". Strange.
Could anyone give this code a whirl and keep me from losing my sanity?
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3991174#3991174
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3991174
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user