Index: java/org/apache/catalina/startup/ContextConfig.java =================================================================== --- java/org/apache/catalina/startup/ContextConfig.java (révision 1848309) +++ java/org/apache/catalina/startup/ContextConfig.java (copie de travail) @@ -1132,36 +1132,7 @@ } if (!webXml.isMetadataComplete() || typeInitializerMap.size() > 0) { - // Step 4. Process /WEB-INF/classes for annotations and - // @HandlesTypes matches - Map javaClassCache = new HashMap<>(); - - if (ok) { - WebResource[] webResources = - context.getResources().listResources("/WEB-INF/classes"); - - for (WebResource webResource : webResources) { - // Skip the META-INF directory from any JARs that have been - // expanded in to WEB-INF/classes (sometimes IDEs do this). - if ("META-INF".equals(webResource.getName())) { - continue; - } - processAnnotationsWebResource(webResource, webXml, - webXml.isMetadataComplete(), javaClassCache); - } - } - - // Step 5. Process JARs for annotations and - // @HandlesTypes matches - only need to process those fragments we - // are going to use (remember orderedFragments includes any - // container fragments) - if (ok) { - processAnnotations( - orderedFragments, webXml.isMetadataComplete(), javaClassCache); - } - - // Cache, if used, is no longer required so clear it - javaClassCache.clear(); + processClasses(webXml, orderedFragments); } if (!webXml.isMetadataComplete()) { @@ -1236,7 +1207,40 @@ } } + protected void processClasses(WebXml webXml, Set orderedFragments) { + // Step 4. Process /WEB-INF/classes for annotations and + // @HandlesTypes matches + Map javaClassCache = new HashMap<>(); + if (ok) { + WebResource[] webResources = + context.getResources().listResources("/WEB-INF/classes"); + + for (WebResource webResource : webResources) { + // Skip the META-INF directory from any JARs that have been + // expanded in to WEB-INF/classes (sometimes IDEs do this). + if ("META-INF".equals(webResource.getName())) { + continue; + } + processAnnotationsWebResource(webResource, webXml, + webXml.isMetadataComplete(), javaClassCache); + } + } + + // Step 5. Process JARs for annotations and + // @HandlesTypes matches - only need to process those fragments we + // are going to use (remember orderedFragments includes any + // container fragments) + if (ok) { + processAnnotations( + orderedFragments, webXml.isMetadataComplete(), javaClassCache); + } + + // Cache, if used, is no longer required so clear it + javaClassCache.clear(); + } + + private void configureContext(WebXml webxml) { // As far as possible, process in alphabetical order so it is easy to // check everything is present @@ -2109,6 +2113,10 @@ return; } + processClass(fragment, clazz); + } + + protected void processClass(WebXml fragment, JavaClass clazz) { AnnotationEntry[] annotationsEntries = clazz.getAnnotationEntries(); if (annotationsEntries != null) { String className = clazz.getClassName();