annotation must be scanned regardless of the version of web.xml
unless metadata-complete is explicitly set to true
------------------------------------------------------------------------------------------------------------------
Key: WFLY-4839
URL:
https://issues.jboss.org/browse/WFLY-4839
Project: WildFly
Issue Type: Bug
Components: Web (Undertow)
Affects Versions: 10.0.0.Alpha4
Reporter: Chao Wang
Assignee: Chao Wang
Fix For: 10.0.0.Beta2
{noformat}
### Description of problem:
Annotation must be scanned regardless of the version of web.xml unless metadata-complete
is explicitly set to true.
Note that Servlet 3.0 specification clearly states the following:
~~~
1.6.2 Processing annotations
In Servlet 2.5, metadata-complete only affected the scanning of annotations at
deployment time. The notion of web-fragments did not exist in servlet 2.5. However
in servlet 3.0 metadata-complete affects scanning of all annotations and web-
fragments at deployment time. The version of the descriptor MUST not affect which
annotations you scan for in a web application. An implementation of a particular
version of the specification MUST scan for all annotations supported in that
configuration, unless metadata-complete is specified.
~~~
### How reproducible:
Anytime
### Steps to Reproduce:
1. Create a library jar which contains a servlet filter using @WebFilter
2. Put the jar under WEB-INF/lib of the web application which web.xml version is 2.3 or
2.4
3. Start JBoss EAP 6
4. Access the web application and see if the servlet filter works
### Actual results:
The servlet filter is not invoked
### Expected results:
The servlet filter is invoked
### Additional info:
It works when the version of web.xml is 2.5 or 3.0
[reply] [−]
Private
Comment 1 Masafumi Miura 2015-06-25 07:18:17 EDT
RED HAT CONFIDENTIAL
It looks metadata-complete is always set to true when the version of web.xml is 2.3 or
2.4 at the line 96 of
web/src/main/java/org/jboss/as/web/deployment/WarMetaDataProcessor.java.
Though Servlet 2.3/2.3 specification does not have metadata-complete attribute, Servlet
3.0 specification states the following. I think it means that the metadata-complete
attribute default to false if it is not specified.
~~~
8.1 Annotations and pluggability
if the metadata-complete attribute is not specified or is set to "false", the
deployment tool must examine the class files of the application for annotations, and
scan for web fragments.
~~~
* web/src/main/java/org/jboss/as/web/deployment/WarMetaDataProcessor.java
76 public class WarMetaDataProcessor implements DeploymentUnitProcessor {
77
78 @Override
79 public void deploy(DeploymentPhaseContext phaseContext) throws
DeploymentUnitProcessingException {
...
87 boolean isComplete = false;
88 WebMetaData specMetaData = warMetaData.getWebMetaData();
89 if (specMetaData != null) {
90 if (specMetaData instanceof Web25MetaData) {
91 isComplete |= ((Web25MetaData) specMetaData).isMetadataComplete();
92 } else if (specMetaData instanceof Web30MetaData) {
93 isComplete |= ((Web30MetaData) specMetaData).isMetadataComplete();
94 } else {
95 // Any web.xml 2.4 or earlier deployment is metadata complete
96 isComplete = true;
97 }
98 }
99
{noformat}