Bug 52669 - Annotation processing, in WEB-INF/classes, for Servlets/Listeners/Filters is skipped when the web app is not extracted, classes do not have packages and for some embedded scenarios
Annotation processing, in WEB-INF/classes, for Servlets/Listeners/Filters is ...
Status: RESOLVED FIXED
Product: Tomcat 7
Classification: Unclassified
Component: Catalina
7.0.25
All All
: P2 normal (vote)
: ---
Assigned To: Tomcat Developers Mailing List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2012-02-14 21:39 UTC by Violeta Georgieva
Modified: 2012-02-16 12:23 UTC (History)
1 user (show)



Attachments
screenshot1 (85.85 KB, image/png)
2012-02-14 21:40 UTC, Violeta Georgieva
Details
screenshot2 (80.43 KB, image/png)
2012-02-14 21:41 UTC, Violeta Georgieva
Details
screenshot3 (68.19 KB, image/png)
2012-02-14 21:41 UTC, Violeta Georgieva
Details
test web app (1.90 KB, application/x-zip-compressed)
2012-02-14 21:43 UTC, Violeta Georgieva
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Violeta Georgieva 2012-02-14 21:39:46 UTC
Hi,

Annotation processing for Servlets/Listeners/Filters is skipped when:
- the web app is not extracted (screenshot1), 
- classes do not have packages (screenshot2),
- for some embedded scenarios (running Tomcat in OSGI environment - screenshot3)

A test web application is attached - test-web-app.war.

I followed the history and the change that introduces that behaviour is made with revision 1210012.



org.apache.catalina.startup.ContextConfig

The annotations are processed correctly in all use cases when we have:

1199    URL webinfClasses;
1200    try {
1201        webinfClasses = context.getServletContext().getResource(
1202                                "/WEB-INF/classes");
1203        processAnnotationsUrl(webinfClasses, webXml);
1204    } catch (MalformedURLException e) {
1205        log.error(sm.getString(
1206                                "contextConfig.webinfClassesUrl"), e);
1207    }


The way how they are processed now is assuming that we will have FirDirContext always.

1196    try {
1197        NamingEnumeration<Binding> listBindings =
1198                    context.getResources().listBindings("/WEB-INF/classes");
1199        while (listBindings.hasMoreElements()) {
1200            Binding binding = listBindings.nextElement();
1201            if (binding.getObject() instanceof FileDirContext) {
1202               File webInfCLassDir =
1203                     new File(
1204                       ((FileDirContext) binding.getObject()).getDocBase());
1205               processAnnotationsFile(webInfCLassDir, webXml);
1206            }
1207        }
1208    } catch (NamingException e) {
1209        log.error(sm.getString(
1210                            "contextConfig.webinfClassesUrl"), e);
1211    }


Regards
Violeta Georgieva
Comment 1 Violeta Georgieva 2012-02-14 21:40:29 UTC
Created attachment 28333 [details]
screenshot1
Comment 2 Violeta Georgieva 2012-02-14 21:41:01 UTC
Created attachment 28334 [details]
screenshot2
Comment 3 Violeta Georgieva 2012-02-14 21:41:35 UTC
Created attachment 28335 [details]
screenshot3
Comment 4 Violeta Georgieva 2012-02-14 21:43:03 UTC
Created attachment 28336 [details]
test web app
Comment 5 Mark Thomas 2012-02-15 21:37:50 UTC
This has been fixed in trunk and 7.0.x and will be included in 7.0.26 onwards.
Comment 6 Violeta Georgieva 2012-02-16 12:23:50 UTC
Thanks!
Violeta