--- java/org/apache/catalina/startup/ContextConfig.java (revision 1672246) +++ java/org/apache/catalina/startup/ContextConfig.java (working copy) @@ -1902,7 +1902,11 @@ jarScanner.scan(context.getServletContext(), context.getLoader().getClassLoader(), callback, pluggabilityJarsToSkip); - + + if(callback.scanFoundNoFragments()){ + log.info(sm.getString("contextConfig.NoFragmentSummary")); + } + return callback.getFragments(); } @@ -2629,7 +2633,8 @@ "META-INF/web-fragment.xml"; private Map fragments = new HashMap(); private final boolean parseRequired; - + private boolean fragmentFound = false; + public FragmentJarScannerCallback(boolean parseRequired) { this.parseRequired = parseRequired; } @@ -2654,6 +2659,7 @@ // impact on distributable fragment.setDistributable(true); } else { + fragmentFound = true; InputSource source = new InputSource( "jar:" + resourceURL.toString() + "!/" + FRAGMENT_LOCATION); @@ -2671,6 +2677,12 @@ fragment.setJarName(extractJarFileName(url)); fragments.put(fragment.getName(), fragment); } + + if (log.isDebugEnabled()) { + if(!fragmentFound){ + log.debug(sm.getString("contextConfig.NoFragmentInJar", resourceURL.toString())); + } + } } private String extractJarFileName(URL input) { @@ -2693,6 +2705,7 @@ try { File fragmentFile = new File(file, FRAGMENT_LOCATION); if (fragmentFile.isFile()) { + fragmentFound = true; stream = new FileInputStream(fragmentFile); InputSource source = new InputSource(fragmentFile.toURI().toURL().toString()); @@ -2717,11 +2730,20 @@ fragment.setJarName(file.getName()); fragments.put(fragment.getName(), fragment); } + if (log.isDebugEnabled()) { + if(!fragmentFound){ + log.debug(sm.getString("contextConfig.NoFragmentInFile", file.getAbsolutePath())); + } + } } public Map getFragments() { return fragments; } + + public boolean scanFoundNoFragments(){ + return !fragmentFound; + } } private static class DefaultWebXmlCacheEntry { --- java/org/apache/catalina/startup/LocalStrings.properties (revision 1672246) +++ java/org/apache/catalina/startup/LocalStrings.properties (working copy) @@ -68,6 +68,9 @@ contextConfig.urlPatternValue=Both the UrlPattern and value attribute were set for the WebServlet annotation on class [{0}] contextConfig.webinfClassesUrl=Unable to determine URL for [{0}] contextConfig.xmlSettings=Context [{0}] will parse web.xml and web-fragment.xml files with validation:{1} and namespaceAware:{2} +contextConfig.NoFragmentInJar=No fragments were found in [{0}]. Consider adding the JAR to the org.apache.catalina.startup.ContextConfig.jarsToSkip property in CATALINA_BASE/conf/catalina.properties file. +contextConfig.NoFragmentInFile=No fragments were found in [{0}]. Consider adding the File to the org.apache.catalina.startup.ContextConfig.jarsToSkip property in CATALINA_BASE/conf/catalina.properties file. +contextConfig.NoFragmentSummary=At least one JAR 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. embedded.noEngines=No engines have been defined yet embedded.notmp=Cannot find specified temporary folder at {0} embedded.authenticatorNotInstanceOfValve=Specified Authenticator is not a Valve @@ -124,8 +127,11 @@ tldConfig.cce=Lifecycle event data object {0} is not a Context tldConfig.dirFail=Failed to process directory [{0}] for TLD files tldConfig.dirScan=Scanning for TLD files in directory [{0}] +tldConfig.noTldInDir=No TLD files were found in directory [{0}]. tldConfig.execute=Error processing TLD files for context with name [{0}] tldConfig.jarFail=Failed to process JAR [{0}] for TLD files +tldConfig.noTldInJar=No TLD files were found in [{0}]. Consider adding the JAR to the org.apache.catalina.startup.TldConfig.jarsToSkip property in CATALINA_BASE/conf/catalina.properties file. +tldConfig.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. tldConfig.webinfFail=Failed to process TLD found at [{0}] tldConfig.webinfScan=Scanning WEB-INF for TLD files in [{0}] tldConfig.webxmlAdd=Adding path [{0}] for URI [{1}] --- java/org/apache/catalina/startup/TldConfig.java (revision 1672246) +++ java/org/apache/catalina/startup/TldConfig.java (working copy) @@ -266,10 +266,16 @@ // Stages 3b & 4 JarScanner jarScanner = context.getJarScanner(); + + TldJarScannerCallback objCallBack = new TldJarScannerCallback(); jarScanner.scan(context.getServletContext(), context.getLoader().getClassLoader(), - new TldJarScannerCallback(), noTldJars); + objCallBack, noTldJars); + if(objCallBack.scanFoundNoTLDs()){ + log.info(sm.getString("tldConfig.noTldSummary")); + } + // Now add all the listeners we found to the listeners for this context String list[] = getTldListeners(); @@ -290,10 +296,11 @@ } private class TldJarScannerCallback implements JarScannerCallback { - + boolean tldFound = false; + @Override public void scan(JarURLConnection urlConn) throws IOException { - tldScanJar(urlConn); + tldFound = tldScanJar(urlConn); } @Override @@ -300,9 +307,13 @@ public void scan(File file) { File metaInf = new File(file, "META-INF"); if (metaInf.isDirectory()) { - tldScanDir(metaInf); + tldFound = tldScanDir(metaInf); } } + + private boolean scanFoundNoTLDs() { + return !tldFound; + } } // -------------------------------------------------------- Private Methods @@ -432,8 +443,8 @@ * * Keep in sync with o.a.j.comiler.TldLocationsCache */ - private void tldScanDir(File start) { - + private boolean tldScanDir(File start) { + boolean isFound = false; if (log.isTraceEnabled()) { log.trace(sm.getString("tldConfig.dirScan", start.getAbsolutePath())); } @@ -446,6 +457,7 @@ tldScanDir(fileList[i]); } else if (fileList[i].getAbsolutePath().endsWith(TLD_EXT)) { InputStream stream = null; + isFound = true; try { stream = new FileInputStream(fileList[i]); XmlErrorHandler handler = tldScanStream(stream); @@ -465,7 +477,13 @@ } } } - } + } + if(!isFound){ + if (log.isDebugEnabled()) { + log.debug(sm.getString("tldConfig.noTldInDir", start.getAbsolutePath())); + } + } + return isFound; } /* @@ -476,11 +494,11 @@ * * Keep in sync with o.a.j.comiler.TldLocationsCache */ - private void tldScanJar(JarURLConnection jarConn) { + private boolean tldScanJar(JarURLConnection jarConn) { Jar jar = null; InputStream is; - + boolean isFound = false; try { jar = JarFactory.newInstance(jarConn.getURL()); @@ -489,6 +507,7 @@ while (entryName != null) { if (entryName.startsWith("META-INF/") && entryName.endsWith(".tld")) { + isFound = true; is = null; try { is = jar.getEntryInputStream(); @@ -507,6 +526,12 @@ jar.nextEntry(); entryName = jar.getEntryName(); } + if(!isFound){ + if (log.isDebugEnabled()) { + log.debug(sm.getString("tldConfig.noTldInJar", + jarConn.getURL().getFile())); + } + } } catch (IOException ioe) { log.warn(sm.getString("tldConfig.jarFail", jarConn.getURL()), ioe); } finally { @@ -514,6 +539,7 @@ jar.close(); } } + return isFound; }