Created attachment 28623[details]
patch that shows the processing of the servlet's superclass injections
Hi folks,
I've been running Tomcat 7.0.26 in a JEE container against the EE6 Web Profile CTS.
In many of the tests there is the following scenario: A servlet 'X' extends a regular class 'Y'. An env-entry element for a field in 'Y' with injection-target-class equal to 'Y' is defined in the app's web.xml. The injection-target-name points to a field that is not annotated.
When the app boots and Tomcat handles the injections for the servlet it processes only those that are defined explicitly for the 'X' servlet's class name, ignoring its superclasses.
I'm attaching a patch I made on top of 7.0.x/trunk that fixed the issue. It's quite small.
I believe Tomcat should respect the injections for the servlet's superclasses. What do you think is the right behavior?
Thank you,
Bobby

Hi,
In the Java Platform EE 6 Spec, EE.5.2.5. Annotations and Injection, they specify that resource annotations may appear on any superclass of the class.
Annotations and inheritance topic is described also on the wiki http://java.net/projects/javaee-spec/pages/AnnotationRules
“In general, annotations on interfaces are ignored.”
However there are specified also exceptions of the rule.
For our use case – resource annotations (@Resource, @EJB etc.) and injection target classes – I think that we should ignore them.
Regards
Violeta

This is ASF Bugzilla: the Apache Software Foundation bug system. In case
of problems with the functioning of ASF Bugzilla, please contact
bugzilla-admin@apache.org.
Please Note: this e-mail address is only for reporting problems
with ASF Bugzilla. Mail about any other subject will be silently
ignored.