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.
getAnnotations() is empty in ejb jar
-
13-10-2022 - |
문제
Steps to reproduce:
- Create ejb project. (For example: Project1)
Create annotation class (For example: Test.class):
@Retention(RetentionPolicy.RUNTIME) public @interface Test { }
Create a simple java project. (For example: Project2)
- Add Project1 as an ejb dependency to Project2.
Create simple class (For example: TestModel) and apply @Test annotation to it:
@Test public class TestModel { ... }
Create ear project. (For example: Project3)
Create ejb-module in Project3. (For example: Project3-ejb)
- Add Project2 as a jar dependency to Project3-ejb.
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); } } }
- Clean, build and deploy Project3 to glassfish 3 or 4.
In server output you will see 0. Why?
해결책
제휴하지 않습니다 StackOverflow