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

(-)java/org/apache/catalina/startup/ContextConfig.java (-6 / +27 lines)
Lines 1871-1876 Link Here
1871
        jarScanner.scan(JarScanType.PLUGGABILITY,
1871
        jarScanner.scan(JarScanType.PLUGGABILITY,
1872
                context.getServletContext(), callback);
1872
                context.getServletContext(), callback);
1873
1873
1874
        if(callback.scanFoundNoFragments()){
1875
            log.info(sm.getString("contextConfig.NoFragmentSummary"));
1876
        }
1877
        
1874
        if (!callback.isOk()) {
1878
        if (!callback.isOk()) {
1875
            ok = false;
1879
            ok = false;
1876
        }
1880
        }
Lines 1950-1956 Link Here
1950
1954
1951
    protected void processAnnotationsJar(URL url, WebXml fragment,
1955
    protected void processAnnotationsJar(URL url, WebXml fragment,
1952
            boolean handlesTypesOnly) {
1956
            boolean handlesTypesOnly) {
1953
1957
        
1958
        boolean annotationsFound = false;
1954
        try (Jar jar = JarFactory.newInstance(url)) {
1959
        try (Jar jar = JarFactory.newInstance(url)) {
1955
            jar.nextEntry();
1960
            jar.nextEntry();
1956
            String entryName = jar.getEntryName();
1961
            String entryName = jar.getEntryName();
Lines 1957-1963 Link Here
1957
            while (entryName != null) {
1962
            while (entryName != null) {
1958
                if (entryName.endsWith(".class")) {
1963
                if (entryName.endsWith(".class")) {
1959
                    try (InputStream is = jar.getEntryInputStream()) {
1964
                    try (InputStream is = jar.getEntryInputStream()) {
1960
                        processAnnotationsStream(
1965
                        annotationsFound = processAnnotationsStream(
1961
                                is, fragment, handlesTypesOnly);
1966
                                is, fragment, handlesTypesOnly);
1962
                    } catch (IOException e) {
1967
                    } catch (IOException e) {
1963
                        log.error(sm.getString("contextConfig.inputStreamJar",
1968
                        log.error(sm.getString("contextConfig.inputStreamJar",
Lines 1970-1975 Link Here
1970
                jar.nextEntry();
1975
                jar.nextEntry();
1971
                entryName = jar.getEntryName();
1976
                entryName = jar.getEntryName();
1972
            }
1977
            }
1978
            if (log.isDebugEnabled()) {
1979
                if(annotationsFound){
1980
                    log.debug(sm.getString("contextConfig.annotationsInJar", url.getFile()));
1981
                }else{
1982
                    log.debug(sm.getString("contextConfig.NoAnnotationsInJar", url.getFile()));
1983
                }
1984
            }
1973
        } catch (IOException e) {
1985
        } catch (IOException e) {
1974
            log.error(sm.getString("contextConfig.jarFile", url), e);
1986
            log.error(sm.getString("contextConfig.jarFile", url), e);
1975
        }
1987
        }
Lines 1990-1996 Link Here
1990
            }
2002
            }
1991
        } else if (file.canRead() && file.getName().endsWith(".class")) {
2003
        } else if (file.canRead() && file.getName().endsWith(".class")) {
1992
            try (FileInputStream fis = new FileInputStream(file)) {
2004
            try (FileInputStream fis = new FileInputStream(file)) {
1993
                processAnnotationsStream(fis, fragment, handlesTypesOnly);
2005
                boolean annotationsFound = processAnnotationsStream(fis, fragment, handlesTypesOnly);
2006
                if (log.isDebugEnabled()) {
2007
                    if(annotationsFound){
2008
                        log.debug(sm.getString("contextConfig.annotationsInFile", file.getAbsolutePath()));
2009
                    }else{
2010
                        log.debug(sm.getString("contextConfig.NoAnnotationsInFile", file.getAbsolutePath()));
2011
                    }
2012
                }
1994
            } catch (IOException e) {
2013
            } catch (IOException e) {
1995
                log.error(sm.getString("contextConfig.inputStreamFile",
2014
                log.error(sm.getString("contextConfig.inputStreamFile",
1996
                        file.getAbsolutePath()),e);
2015
                        file.getAbsolutePath()),e);
Lines 2002-2017 Link Here
2002
    }
2021
    }
2003
2022
2004
2023
2005
    protected void processAnnotationsStream(InputStream is, WebXml fragment,
2024
    protected boolean processAnnotationsStream(InputStream is, WebXml fragment,
2006
            boolean handlesTypesOnly)
2025
            boolean handlesTypesOnly)
2007
            throws ClassFormatException, IOException {
2026
            throws ClassFormatException, IOException {
2008
2027
        
2028
        boolean annotationsFound = false;
2009
        ClassParser parser = new ClassParser(is);
2029
        ClassParser parser = new ClassParser(is);
2010
        JavaClass clazz = parser.parse();
2030
        JavaClass clazz = parser.parse();
2011
        checkHandlesTypes(clazz);
2031
        checkHandlesTypes(clazz);
2012
2032
2013
        if (handlesTypesOnly) {
2033
        if (handlesTypesOnly) {
2014
            return;
2034
            return true;
2015
        }
2035
        }
2016
2036
2017
        AnnotationEntry[] annotationsEntries = clazz.getAnnotationEntries();
2037
        AnnotationEntry[] annotationsEntries = clazz.getAnnotationEntries();
Lines 2030-2035 Link Here
2030
                }
2050
                }
2031
            }
2051
            }
2032
        }
2052
        }
2053
        return annotationsFound;
2033
    }
2054
    }
2034
2055
2035
    /**
2056
    /**
(-)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