[GLASSFISH-18326] Logic to decide whether to skip or perform annotation processing of an archive is not spec compliant Created: 05/Feb/12  Updated: 01/Mar/13  Resolved: 01/Mar/13

Status: Resolved
Project: glassfish
Component/s: deployment
Affects Version/s: 3.1
Fix Version/s: 4.0_b79

Type: Bug Priority: Major
Reporter: Sanjeeb Sahoo Assignee: Hong Zhang
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Tags: 3_1_2-exclude

 Description   

The following code in Archivist is looking suspicious. Why are we checking isProcessAnnotation for every descriptor in an archive? Is it not sufficient to just decide whether to process annotation or not based on the version of the primary descriptor of the archive. e.g., think of a WAR with WEB-INF/lib/ejb.jar. Let's say the ejb.jar has DD version 2.1. Are we going to skip annotations of ejb.jar? Similarly consider the opposite case. a WAR with WEB-INF/lib/ejb.jar. Let's say the WAR has web-DD version 2.5, but ejb.jar has version 3.0. Are we going to process annotations of ejb.jar?

protected boolean isProcessAnnotation(T descriptor) {
// if the system property is set to process annotation for pre-JavaEE5
// DD, the semantics of isFull flag is: full attribute is set to
// true in DD. Otherwise the semantics is full attribute set to
// true or it is pre-JavaEE5 DD.
boolean isFull = false;
if (processAnnotationForOldDD)

{ isFull = descriptor.isFullAttribute(); }

else

{ isFull = descriptor.isFullFlag(); }

// only process annotation when these two requirements satisfied:
// 1. It is not a full deployment descriptor
// 2. It is called through dynamic deployment
return (!isFull && annotationProcessingRequested && classLoader != null);
}



 Comments   
Comment by Hong Zhang [ 06/Feb/12 ]

Sahoo, thanks for reporting this. I thought a little more about this later. The metadata-complete attribute is also at module level, what should be the expected behavior for an ejb in war case when the ejb-jar.xml has metadata-complete specified as false and the web.xml has metadata-complete specified as true. Though these two cases are not exactly the same, there are some similiarities. We should probably follow this up with the spec leads to get some clarification.

Comment by Sanjeeb Sahoo [ 07/Feb/12 ]

Good point, Hong. See "20.5.2. war Deployment Descriptor and Annotation Processing" of EJB 3.1 spec for the answer. I think the following row in the table is exposed by this bug:

no ejb-jar.xml in war, war has 2.5 or 3.0 web.xml with metadata-complete=true results in skipping annotation processing for ejbs!

Comment by Hong Zhang [ 01/Mar/13 ]

Thanks for pointing out the relevant section in EJB spec! I have updated the logic of determining whether to process annotations for ejb in war case to conform to the spec now. When there is ejb-jar.xml packaged in ejb in war case, use that to determine whether to process annotations, otherwise use the web.xml packaged in the ejb in war to determine.

Generated at Tue May 05 16:27:39 UTC 2015 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.