View | Details | Raw Unified | Return to bug 56438
Collapse All | Expand All

(-)java/org/apache/catalina/startup/ContextConfig.java (-6 / +28 lines)
Lines 1871-1876 Link Here
1871
1871
1872
        jarScanner.scan(JarScanType.PLUGGABILITY,
1872
        jarScanner.scan(JarScanType.PLUGGABILITY,
1873
                context.getServletContext(), callback);
1873
                context.getServletContext(), callback);
1874
        
1875
        if(callback.scanFoundNoFragments()){
1876
            log.info(sm.getString("contextConfig.NoFragmentSummary"));
1877
        }
1874
1878
1875
        if (!callback.isOk()) {
1879
        if (!callback.isOk()) {
1876
            ok = false;
1880
            ok = false;
Lines 1951-1957 Link Here
1951
1955
1952
    protected void processAnnotationsJar(URL url, WebXml fragment,
1956
    protected void processAnnotationsJar(URL url, WebXml fragment,
1953
            boolean handlesTypesOnly) {
1957
            boolean handlesTypesOnly) {
1954
1958
        
1959
        boolean annotationsFound = false;
1955
        try (Jar jar = JarFactory.newInstance(url)) {
1960
        try (Jar jar = JarFactory.newInstance(url)) {
1956
            jar.nextEntry();
1961
            jar.nextEntry();
1957
            String entryName = jar.getEntryName();
1962
            String entryName = jar.getEntryName();
Lines 1958-1964 Link Here
1958
            while (entryName != null) {
1963
            while (entryName != null) {
1959
                if (entryName.endsWith(".class")) {
1964
                if (entryName.endsWith(".class")) {
1960
                    try (InputStream is = jar.getEntryInputStream()) {
1965
                    try (InputStream is = jar.getEntryInputStream()) {
1961
                        processAnnotationsStream(
1966
                        annotationsFound = processAnnotationsStream(
1962
                                is, fragment, handlesTypesOnly);
1967
                                is, fragment, handlesTypesOnly);
1963
                    } catch (IOException e) {
1968
                    } catch (IOException e) {
1964
                        log.error(sm.getString("contextConfig.inputStreamJar",
1969
                        log.error(sm.getString("contextConfig.inputStreamJar",
Lines 1971-1976 Link Here
1971
                jar.nextEntry();
1976
                jar.nextEntry();
1972
                entryName = jar.getEntryName();
1977
                entryName = jar.getEntryName();
1973
            }
1978
            }
1979
            if (log.isDebugEnabled()) {
1980
                if(annotationsFound){
1981
                    log.debug(sm.getString("contextConfig.annotationsInJar", url.getFile()));
1982
                }else{
1983
                    log.debug(sm.getString("contextConfig.NoAnnotationsInJar", url.getFile()));
1984
                }
1985
            }
1974
        } catch (IOException e) {
1986
        } catch (IOException e) {
1975
            log.error(sm.getString("contextConfig.jarFile", url), e);
1987
            log.error(sm.getString("contextConfig.jarFile", url), e);
1976
        }
1988
        }
Lines 1991-1997 Link Here
1991
            }
2003
            }
1992
        } else if (file.canRead() && file.getName().endsWith(".class")) {
2004
        } else if (file.canRead() && file.getName().endsWith(".class")) {
1993
            try (FileInputStream fis = new FileInputStream(file)) {
2005
            try (FileInputStream fis = new FileInputStream(file)) {
1994
                processAnnotationsStream(fis, fragment, handlesTypesOnly);
2006
                boolean annotationsFound = processAnnotationsStream(fis, fragment, handlesTypesOnly);
2007
                if (log.isDebugEnabled()) {
2008
                    if(annotationsFound){
2009
                        log.debug(sm.getString("contextConfig.annotationsInFile", file.getAbsolutePath()));
2010
                    }else{
2011
                        log.debug(sm.getString("contextConfig.NoAnnotationsInFile", file.getAbsolutePath()));
2012
                    }
2013
                }
1995
            } catch (IOException e) {
2014
            } catch (IOException e) {
1996
                log.error(sm.getString("contextConfig.inputStreamFile",
2015
                log.error(sm.getString("contextConfig.inputStreamFile",
1997
                        file.getAbsolutePath()),e);
2016
                        file.getAbsolutePath()),e);
Lines 2003-2022 Link Here
2003
    }
2022
    }
2004
2023
2005
2024
2006
    protected void processAnnotationsStream(InputStream is, WebXml fragment,
2025
    protected boolean processAnnotationsStream(InputStream is, WebXml fragment,
2007
            boolean handlesTypesOnly)
2026
            boolean handlesTypesOnly)
2008
            throws ClassFormatException, IOException {
2027
            throws ClassFormatException, IOException {
2009
2028
        
2029
        boolean annotationsFound = false;
2010
        ClassParser parser = new ClassParser(is);
2030
        ClassParser parser = new ClassParser(is);
2011
        JavaClass clazz = parser.parse();
2031
        JavaClass clazz = parser.parse();
2012
        checkHandlesTypes(clazz);
2032
        checkHandlesTypes(clazz);
2013
2033
2014
        if (handlesTypesOnly) {
2034
        if (handlesTypesOnly) {
2015
            return;
2035
            return true;
2016
        }
2036
        }
2017
2037
2018
        AnnotationEntry[] annotationsEntries = clazz.getAnnotationEntries();
2038
        AnnotationEntry[] annotationsEntries = clazz.getAnnotationEntries();
2019
        if (annotationsEntries != null) {
2039
        if (annotationsEntries != null) {
2040
            annotationsFound = true;
2020
            String className = clazz.getClassName();
2041
            String className = clazz.getClassName();
2021
            for (AnnotationEntry ae : annotationsEntries) {
2042
            for (AnnotationEntry ae : annotationsEntries) {
2022
                String type = ae.getAnnotationType();
2043
                String type = ae.getAnnotationType();
Lines 2031-2036 Link Here
2031
                }
2052
                }
2032
            }
2053
            }
2033
        }
2054
        }
2055
        return annotationsFound;
2034
    }
2056
    }
2035
2057
2036
    /**
2058
    /**
(-)java/org/apache/catalina/startup/LocalStrings.properties (+9 lines)
Lines 54-59 Link Here
54
contextConfig.jspFile.warning=WARNING: JSP file {0} must start with a ''/'' in Servlet 2.4
54
contextConfig.jspFile.warning=WARNING: JSP file {0} must start with a ''/'' in Servlet 2.4
55
contextConfig.missingRealm=No Realm has been configured to authenticate against
55
contextConfig.missingRealm=No Realm has been configured to authenticate against
56
contextConfig.resourceJarFail=Failed to processes JAR found at URL [{0}] for static resources to be included in context with name [{0}]
56
contextConfig.resourceJarFail=Failed to processes JAR found at URL [{0}] for static resources to be included in context with name [{0}]
57
contextConfig.NoStaticResourceInJar=No static resources were found in jar [{0}].
58
contextConfig.staticResourceInJar=Static resources were found in jar [{0}].
57
contextConfig.role.auth=Security role name {0} used in an <auth-constraint> without being defined in a <security-role>
59
contextConfig.role.auth=Security role name {0} used in an <auth-constraint> without being defined in a <security-role>
58
contextConfig.role.link=Security role name {0} used in a <role-link> without being defined in a <security-role>
60
contextConfig.role.link=Security role name {0} used in a <role-link> without being defined in a <security-role>
59
contextConfig.role.runas=Security role name {0} used in a <run-as> without being defined in a <security-role>
61
contextConfig.role.runas=Security role name {0} used in a <run-as> without being defined in a <security-role>
Lines 67-72 Link Here
67
contextConfig.urlPatternValue=Both the UrlPattern and value attribute were set for the WebServlet annotation on class [{0}]
69
contextConfig.urlPatternValue=Both the UrlPattern and value attribute were set for the WebServlet annotation on class [{0}]
68
contextConfig.webinfClassesUrl=Unable to determine URL for [{0}]
70
contextConfig.webinfClassesUrl=Unable to determine URL for [{0}]
69
contextConfig.xmlSettings=Context [{0}] will parse web.xml and web-fragment.xml files with validation:{1} and namespaceAware:{2}
71
contextConfig.xmlSettings=Context [{0}] will parse web.xml and web-fragment.xml files with validation:{1} and namespaceAware:{2}
72
contextConfig.NoAnnotationsInJar=No annotations were found in jar [{0}]. Consider adding the JAR to the org.apache.catalina.startup.ContextConfig.jarsToSkip property in CATALINA_BASE/conf/catalina.properties file.
73
contextConfig.annotationsInJar=Annotations were found in jar [{0}].
74
contextConfig.NoAnnotationsInFile=No annotations were found in file [{0}]. Consider adding the File to the org.apache.catalina.startup.ContextConfig.jarsToSkip property in CATALINA_BASE/conf/catalina.properties file.
75
contextConfig.annotationsInFile=Annotations were found in file [{0}].
76
contextConfig.NoFragmentSummary=At least one JAR or file was scanned for fragments yet contained no fragments. Enable debug logging for this logger for a complete list of JARs that were scanned but no fragments were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
77
contextConfig.NoAnnotationsInScInitializer=No annotations were found in servlet container initializer.
78
contextConfig.annotationsInScInitializer=Annotations were found in servlet container initializer.
70
embedded.noEngines=No engines have been defined yet
79
embedded.noEngines=No engines have been defined yet
71
embedded.notmp=Cannot find specified temporary folder at {0}
80
embedded.notmp=Cannot find specified temporary folder at {0}
72
embedded.authenticatorNotInstanceOfValve=Specified Authenticator is not a Valve
81
embedded.authenticatorNotInstanceOfValve=Specified Authenticator is not a Valve
(-)java/org/apache/jasper/resources/LocalStrings.properties (-1 / +1 lines)
Lines 395-401 Link Here
395
jsp.tldCache.tldInDir=TLD files were found in directory [{0}].
395
jsp.tldCache.tldInDir=TLD files were found in directory [{0}].
396
jsp.tldCache.noTldInJar=No TLD files were found in [{0}]. Consider adding the JAR to the tomcat.util.scan.StandardJarScanFilter.jarsToSkip property in CATALINA_BASE/conf/catalina.properties file.
396
jsp.tldCache.noTldInJar=No TLD files were found in [{0}]. Consider adding the JAR to the tomcat.util.scan.StandardJarScanFilter.jarsToSkip property in CATALINA_BASE/conf/catalina.properties file.
397
jsp.tldCache.tldInJar=TLD files were found in JAR [{0}].
397
jsp.tldCache.tldInJar=TLD files were found in JAR [{0}].
398
jsp.tldCache.noTldSummary=At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
398
jsp.tldCache.noTldSummary=At least one JAR or file was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs or files that were scanned but no TLDs were found in them. Skipping unneeded these during scanning can improve startup time and JSP compilation time.
399
399
400
#ELInterpreter
400
#ELInterpreter
401
jsp.error.el_interpreter_class.instantiation=Failed to load or instantiate ELInterpreter class [{0}]
401
jsp.error.el_interpreter_class.instantiation=Failed to load or instantiate ELInterpreter class [{0}]
(-)java/org/apache/jasper/servlet/TldScanner.java (-6 / +8 lines)
Lines 292-302 Link Here
292
    class TldScannerCallback implements JarScannerCallback {
292
    class TldScannerCallback implements JarScannerCallback {
293
        private boolean foundJarWithoutTld = false;
293
        private boolean foundJarWithoutTld = false;
294
        private boolean foundFileWithoutTld = false;
294
        private boolean foundFileWithoutTld = false;
295
295
        private boolean found = false;
296
        
296
        @Override
297
        @Override
297
        public void scan(JarURLConnection urlConn, String webappPath,
298
        public void scan(JarURLConnection urlConn, String webappPath,
298
                boolean isWebapp) throws IOException {
299
                boolean isWebapp) throws IOException {
299
            boolean found = false;
300
            found = false;
300
            URL jarURL;
301
            URL jarURL;
301
            try (Jar jar = JarFactory.newInstance(urlConn.getURL())) {
302
            try (Jar jar = JarFactory.newInstance(urlConn.getURL())) {
302
                jarURL = jar.getJarFileURL();
303
                jarURL = jar.getJarFileURL();
Lines 337-343 Link Here
337
            if (!metaInf.isDirectory()) {
338
            if (!metaInf.isDirectory()) {
338
                return;
339
                return;
339
            }
340
            }
340
            foundFileWithoutTld = false;
341
            found = false;
341
            final Path filePath = file.toPath();
342
            final Path filePath = file.toPath();
342
            Files.walkFileTree(metaInf.toPath(), new SimpleFileVisitor<Path>() {
343
            Files.walkFileTree(metaInf.toPath(), new SimpleFileVisitor<Path>() {
343
                @Override
344
                @Override
Lines 349-355 Link Here
349
                        return FileVisitResult.CONTINUE;
350
                        return FileVisitResult.CONTINUE;
350
                    }
351
                    }
351
352
352
                    foundFileWithoutTld = true;
353
                    found = true;
353
                    String resourcePath;
354
                    String resourcePath;
354
                    if (webappPath == null) {
355
                    if (webappPath == null) {
355
                        resourcePath = null;
356
                        resourcePath = null;
Lines 372-383 Link Here
372
                    return FileVisitResult.CONTINUE;
373
                    return FileVisitResult.CONTINUE;
373
                }
374
                }
374
            });
375
            });
375
            if (foundFileWithoutTld) {
376
            if (found) {                
376
                if (log.isDebugEnabled()) {
377
                if (log.isDebugEnabled()) {
377
                    log.debug(Localizer.getMessage("jsp.tldCache.tldInDir",
378
                    log.debug(Localizer.getMessage("jsp.tldCache.tldInDir",
378
                            file.getAbsolutePath()));
379
                            file.getAbsolutePath()));
379
                }
380
                }
380
            } else {
381
            } else {
382
                foundFileWithoutTld = true;
381
                if (log.isDebugEnabled()) {
383
                if (log.isDebugEnabled()) {
382
                    log.debug(Localizer.getMessage("jsp.tldCache.noTldInDir",
384
                    log.debug(Localizer.getMessage("jsp.tldCache.noTldInDir",
383
                            file.getAbsolutePath()));
385
                            file.getAbsolutePath()));
Lines 402-408 Link Here
402
404
403
405
404
        boolean scanFoundNoTLDs() {
406
        boolean scanFoundNoTLDs() {
405
            return foundJarWithoutTld;
407
            return foundJarWithoutTld || foundFileWithoutTld;
406
        }
408
        }
407
    }
409
    }
408
}
410
}
(-)java/org/apache/tomcat/util/descriptor/web/FragmentJarScannerCallback.java (-1 / +40 lines)
Lines 25-31 Link Here
25
import java.util.HashMap;
25
import java.util.HashMap;
26
import java.util.Map;
26
import java.util.Map;
27
27
28
import org.apache.juli.logging.Log;
29
import org.apache.juli.logging.LogFactory;
28
import org.apache.tomcat.JarScannerCallback;
30
import org.apache.tomcat.JarScannerCallback;
31
import org.apache.tomcat.util.res.StringManager;
29
import org.apache.tomcat.util.scan.Jar;
32
import org.apache.tomcat.util.scan.Jar;
30
import org.apache.tomcat.util.scan.JarFactory;
33
import org.apache.tomcat.util.scan.JarFactory;
31
import org.xml.sax.InputSource;
34
import org.xml.sax.InputSource;
Lines 35-40 Link Here
35
*/
38
*/
36
public class FragmentJarScannerCallback implements JarScannerCallback {
39
public class FragmentJarScannerCallback implements JarScannerCallback {
37
40
41
    private static final StringManager sm =
42
            StringManager.getManager(Constants.PACKAGE_NAME);
43
44
    private static final Log log = LogFactory.getLog(FragmentJarScannerCallback.class);
45
    
38
    private static final String FRAGMENT_LOCATION =
46
    private static final String FRAGMENT_LOCATION =
39
        "META-INF/web-fragment.xml";
47
        "META-INF/web-fragment.xml";
40
    private final WebXmlParser webXmlParser;
48
    private final WebXmlParser webXmlParser;
Lines 42-48 Link Here
42
    private final boolean parseRequired;
50
    private final boolean parseRequired;
43
    private final Map<String,WebXml> fragments = new HashMap<>();
51
    private final Map<String,WebXml> fragments = new HashMap<>();
44
    private boolean ok  = true;
52
    private boolean ok  = true;
45
53
    private boolean foundJarWithoutFragments = false;
54
    private boolean foundFileWithoutFragments = false;
55
    private boolean found = false;
56
    
46
    public FragmentJarScannerCallback(WebXmlParser webXmlParser, boolean delegate,
57
    public FragmentJarScannerCallback(WebXmlParser webXmlParser, boolean delegate,
47
            boolean parseRequired) {
58
            boolean parseRequired) {
48
        this.webXmlParser = webXmlParser;
59
        this.webXmlParser = webXmlParser;
Lines 54-59 Link Here
54
    public void scan(JarURLConnection jarConn, String webappPath, boolean isWebapp)
65
    public void scan(JarURLConnection jarConn, String webappPath, boolean isWebapp)
55
            throws IOException {
66
            throws IOException {
56
67
68
        found = false;
57
        URL url = jarConn.getURL();
69
        URL url = jarConn.getURL();
58
        URL resourceURL = jarConn.getJarFileURL();
70
        URL resourceURL = jarConn.getJarFileURL();
59
        Jar jar = null;
71
        Jar jar = null;
Lines 77-82 Link Here
77
                // distributable
89
                // distributable
78
                fragment.setDistributable(true);
90
                fragment.setDistributable(true);
79
            } else {
91
            } else {
92
                found = true;
80
                InputSource source = new InputSource(
93
                InputSource source = new InputSource(
81
                        "jar:" + resourceURL.toString() + "!/" + FRAGMENT_LOCATION);
94
                        "jar:" + resourceURL.toString() + "!/" + FRAGMENT_LOCATION);
82
                source.setByteStream(is);
95
                source.setByteStream(is);
Lines 95-100 Link Here
95
            fragment.setJarName(extractJarFileName(url));
108
            fragment.setJarName(extractJarFileName(url));
96
            fragments.put(fragment.getName(), fragment);
109
            fragments.put(fragment.getName(), fragment);
97
        }
110
        }
111
        if(found){
112
            if (log.isDebugEnabled()) {
113
                log.debug(sm.getString("fragmentJarScannerCallBack.fragmentInJar", resourceURL.toString()));
114
            }
115
        }else{
116
            foundJarWithoutFragments = true;
117
            if (log.isDebugEnabled()) {
118
                log.debug(sm.getString("fragmentJarScannerCallBack.NoFragmentInJar", resourceURL.toString()));
119
            }
120
        }
98
    }
121
    }
99
122
100
    private String extractJarFileName(URL input) {
123
    private String extractJarFileName(URL input) {
Lines 111-116 Link Here
111
    @Override
134
    @Override
112
    public void scan(File file, String webappPath, boolean isWebapp) throws IOException {
135
    public void scan(File file, String webappPath, boolean isWebapp) throws IOException {
113
136
137
        found = false;
114
        WebXml fragment = new WebXml();
138
        WebXml fragment = new WebXml();
115
        fragment.setWebappJar(isWebapp);
139
        fragment.setWebappJar(isWebapp);
116
        fragment.setDelegate(delegate);
140
        fragment.setDelegate(delegate);
Lines 118-123 Link Here
118
        File fragmentFile = new File(file, FRAGMENT_LOCATION);
142
        File fragmentFile = new File(file, FRAGMENT_LOCATION);
119
        try {
143
        try {
120
            if (fragmentFile.isFile()) {
144
            if (fragmentFile.isFile()) {
145
                found = true;
121
                try (InputStream stream = new FileInputStream(fragmentFile)) {
146
                try (InputStream stream = new FileInputStream(fragmentFile)) {
122
                    InputSource source =
147
                    InputSource source =
123
                        new InputSource(fragmentFile.toURI().toURL().toString());
148
                        new InputSource(fragmentFile.toURI().toURL().toString());
Lines 139-144 Link Here
139
            fragment.setJarName(file.getName());
164
            fragment.setJarName(file.getName());
140
            fragments.put(fragment.getName(), fragment);
165
            fragments.put(fragment.getName(), fragment);
141
        }
166
        }
167
        if(found){            
168
            if (log.isDebugEnabled()) {
169
                log.debug(sm.getString("fragmentJarScannerCallBack.fragmentInFile", file.getAbsolutePath()));
170
            }
171
        }else{
172
            foundFileWithoutFragments = true;
173
            if (log.isDebugEnabled()) {
174
                log.debug(sm.getString("fragmentJarScannerCallBack.NoFragmentInFile", file.getAbsolutePath()));
175
            }
176
        }
142
    }
177
    }
143
178
144
179
Lines 156-159 Link Here
156
    public Map<String,WebXml> getFragments() {
191
    public Map<String,WebXml> getFragments() {
157
        return fragments;
192
        return fragments;
158
    }
193
    }
194
    
195
    public boolean scanFoundNoFragments(){
196
        return foundJarWithoutFragments || foundFileWithoutFragments;
197
    }
159
}
198
}
(-)java/org/apache/tomcat/util/descriptor/web/LocalStrings.properties (+4 lines)
Lines 13-18 Link Here
13
# See the License for the specific language governing permissions and
13
# See the License for the specific language governing permissions and
14
# limitations under the License.
14
# limitations under the License.
15
filterDef.invalidFilterName=Invalid <filter-name> [{0}] in filter definition.
15
filterDef.invalidFilterName=Invalid <filter-name> [{0}] in filter definition.
16
fragmentJarScannerCallBack.NoFragmentInJar=No fragments were found in jar [{0}]. Consider adding the JAR to the org.apache.catalina.startup.ContextConfig.jarsToSkip property in CATALINA_BASE/conf/catalina.properties file.
17
fragmentJarScannerCallBack.fragmentInJar=Fragments were found in jar [{0}].
18
fragmentJarScannerCallBack.NoFragmentInFile=No fragments were found in file [{0}]. Consider adding the File to the org.apache.catalina.startup.ContextConfig.jarsToSkip property in CATALINA_BASE/conf/catalina.properties file.
19
fragmentJarScannerCallBack.fragmentInFile=Fragments were found in file [{0}].
16
20
17
securityConstraint.uncoveredHttpMethod=For security constraints with URL pattern [{0}] only the HTTP methods [{1}] are covered. All other methods are uncovered.
21
securityConstraint.uncoveredHttpMethod=For security constraints with URL pattern [{0}] only the HTTP methods [{1}] are covered. All other methods are uncovered.
18
securityConstraint.uncoveredHttpMethodFix=Adding security constraints with URL pattern [{0}] to deny access with the uncovered HTTP methods that are not one of the following [{1}]
22
securityConstraint.uncoveredHttpMethodFix=Adding security constraints with URL pattern [{0}] to deny access with the uncovered HTTP methods that are not one of the following [{1}]

Return to bug 56438