문제

Steps to reproduce:

  1. Create ejb project. (For example: Project1)
  2. Create annotation class (For example: Test.class):

    @Retention(RetentionPolicy.RUNTIME)
    public @interface Test {
    
    }
    
  3. Create a simple java project. (For example: Project2)

  4. Add Project1 as an ejb dependency to Project2.
  5. Create simple class (For example: TestModel) and apply @Test annotation to it:

    @Test
    public class TestModel {
        ...
    }
    
  6. Create ear project. (For example: Project3)

  7. Create ejb-module in Project3. (For example: Project3-ejb)

  8. Add Project2 as a jar dependency to Project3-ejb.
  9. Create stateless timer in Project3-ejb:

    @Stateless
    @LocalBean
    public class Timer {
    
        @Schedule(minute = "*", second = "*", hour = "*")
    
        public void myTimer() {
            try {
                System.out.println(TestModel.class.getAnnotations().length);
            } catch (SecurityException ex) {
                logger.log(Level.SEVERE, null, ex);
            }
        }
    }
    
  10. Clean, build and deploy Project3 to glassfish 3 or 4.

In server output you will see 0. Why?

도움이 되었습니까?

해결책

I found that this problem is specific only for glassfish servers. If I deploy Project3 to Jboss server, I will see 1 in the server output. Seems, this is glassfish bug. I created ticket: https://java.net/jira/browse/GLASSFISH-20990 Also, if in step 4 add Project1 as jar dependency, I see 1 in server output.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top