Issue Details (XML | Word | Printable)

Key: GLASSFISH-20990
Type: Bug Bug
Status: Resolved Resolved
Resolution: Invalid
Priority: Major Major
Assignee: Sanjeeb Sahoo
Reporter: winechess
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
glassfish

getDecalredField("field").getAnnotations() return empty array

Created: 19/Feb/14 12:56 PM   Updated: 19/Feb/14 03:33 PM   Resolved: 19/Feb/14 03:33 PM
Component/s: classloader
Affects Version/s: 3.1.2.2, 4.0
Fix Version/s: None

Time Tracking:
Not Specified

Environment:

Ubuntu 13.04, GlassFish Server Open Source Edition 4.0 (build 89)


Tags: ejb annotations glassfish4 glassfish3
Participants: Sanjeeb Sahoo and winechess


 Description  « Hide

Steps to reproduce (all projects are maven based, for usual projects result will be the same):

1. Create EJB project (Project1) with annotation @Test.
2. Create simple java project (Project2) and add Project1 as ejb dependency.
3. In Project2 create class Model and apply annotation @Test on it.
4. Create ear project (Project3) with ejb module Project3-ejb.
5. Add Project2 as a dependency to Project3-ejb.
6. Create timer in Project3-ejb and output TestModel.class.getAnnotations().length.
7. Clean, build and deploy Project3 to glassfish3 or 4.

Result: You will see 0 in server output
Expected result: 1

Note 1: if add Project1 as a jar dependency, in step 2, result will be 1.

Note 2: if deploy Project3 to jboss 7 or 8, result will be 1.



winechess added a comment - 19/Feb/14 01:01 PM

Sorry, forgot to change title from "getDecalredField("field").getAnnotations() return empty array" to "Class.getAnnotations() return empty array"


Sanjeeb Sahoo added a comment - 19/Feb/14 03:33 PM

I think you are making incorrect assumptions about class loading dependencies between various modules. Two ejb jars don't necessarily share the same class loader as per Java EE rules. Please refer to Java EE platform spec for more details.