ASF Bugzilla – Attachment 32748 Details for
Bug 56438
If jar scan does not find context config or TLD config, log a message
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Fix for printing log messages in case of contextconfig scan-Tomcat8
56438_fix.diff (text/plain), 15.86 KB, created by
VIN
on 2015-05-21 09:03:29 UTC
(
hide
)
Description:
Fix for printing log messages in case of contextconfig scan-Tomcat8
Filename:
MIME Type:
Creator:
VIN
Created:
2015-05-21 09:03:29 UTC
Size:
15.86 KB
patch
obsolete
>Index: java/org/apache/catalina/startup/ContextConfig.java >=================================================================== >--- java/org/apache/catalina/startup/ContextConfig.java (revision 1680736) >+++ java/org/apache/catalina/startup/ContextConfig.java (working copy) >@@ -1871,6 +1871,10 @@ > > jarScanner.scan(JarScanType.PLUGGABILITY, > context.getServletContext(), callback); >+ >+ if(callback.scanFoundNoFragments()){ >+ log.info(sm.getString("contextConfig.NoFragmentSummary")); >+ } > > if (!callback.isOk()) { > ok = false; >@@ -1951,7 +1955,8 @@ > > protected void processAnnotationsJar(URL url, WebXml fragment, > boolean handlesTypesOnly) { >- >+ >+ boolean annotationsFound = false; > try (Jar jar = JarFactory.newInstance(url)) { > jar.nextEntry(); > String entryName = jar.getEntryName(); >@@ -1958,7 +1963,7 @@ > while (entryName != null) { > if (entryName.endsWith(".class")) { > try (InputStream is = jar.getEntryInputStream()) { >- processAnnotationsStream( >+ annotationsFound = processAnnotationsStream( > is, fragment, handlesTypesOnly); > } catch (IOException e) { > log.error(sm.getString("contextConfig.inputStreamJar", >@@ -1971,6 +1976,13 @@ > jar.nextEntry(); > entryName = jar.getEntryName(); > } >+ if (log.isDebugEnabled()) { >+ if(annotationsFound){ >+ log.debug(sm.getString("contextConfig.annotationsInJar", url.getFile())); >+ }else{ >+ log.debug(sm.getString("contextConfig.NoAnnotationsInJar", url.getFile())); >+ } >+ } > } catch (IOException e) { > log.error(sm.getString("contextConfig.jarFile", url), e); > } >@@ -1991,7 +2003,14 @@ > } > } else if (file.canRead() && file.getName().endsWith(".class")) { > try (FileInputStream fis = new FileInputStream(file)) { >- processAnnotationsStream(fis, fragment, handlesTypesOnly); >+ boolean annotationsFound = processAnnotationsStream(fis, fragment, handlesTypesOnly); >+ if (log.isDebugEnabled()) { >+ if(annotationsFound){ >+ log.debug(sm.getString("contextConfig.annotationsInFile", file.getAbsolutePath())); >+ }else{ >+ log.debug(sm.getString("contextConfig.NoAnnotationsInFile", file.getAbsolutePath())); >+ } >+ } > } catch (IOException e) { > log.error(sm.getString("contextConfig.inputStreamFile", > file.getAbsolutePath()),e); >@@ -2003,20 +2022,22 @@ > } > > >- protected void processAnnotationsStream(InputStream is, WebXml fragment, >+ protected boolean processAnnotationsStream(InputStream is, WebXml fragment, > boolean handlesTypesOnly) > throws ClassFormatException, IOException { >- >+ >+ boolean annotationsFound = false; > ClassParser parser = new ClassParser(is); > JavaClass clazz = parser.parse(); > checkHandlesTypes(clazz); > > if (handlesTypesOnly) { >- return; >+ return true; > } > > AnnotationEntry[] annotationsEntries = clazz.getAnnotationEntries(); > if (annotationsEntries != null) { >+ annotationsFound = true; > String className = clazz.getClassName(); > for (AnnotationEntry ae : annotationsEntries) { > String type = ae.getAnnotationType(); >@@ -2031,6 +2052,7 @@ > } > } > } >+ return annotationsFound; > } > > /** >Index: java/org/apache/catalina/startup/LocalStrings.properties >=================================================================== >--- java/org/apache/catalina/startup/LocalStrings.properties (revision 1680736) >+++ java/org/apache/catalina/startup/LocalStrings.properties (working copy) >@@ -54,6 +54,8 @@ > contextConfig.jspFile.warning=WARNING: JSP file {0} must start with a ''/'' in Servlet 2.4 > contextConfig.missingRealm=No Realm has been configured to authenticate against > contextConfig.resourceJarFail=Failed to processes JAR found at URL [{0}] for static resources to be included in context with name [{0}] >+contextConfig.NoStaticResourceInJar=No static resources were found in jar [{0}]. >+contextConfig.staticResourceInJar=Static resources were found in jar [{0}]. > contextConfig.role.auth=Security role name {0} used in an <auth-constraint> without being defined in a <security-role> > contextConfig.role.link=Security role name {0} used in a <role-link> without being defined in a <security-role> > contextConfig.role.runas=Security role name {0} used in a <run-as> without being defined in a <security-role> >@@ -67,6 +69,13 @@ > 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.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. >+contextConfig.annotationsInJar=Annotations were found in jar [{0}]. >+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. >+contextConfig.annotationsInFile=Annotations were found in file [{0}]. >+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. >+contextConfig.NoAnnotationsInScInitializer=No annotations were found in servlet container initializer. >+contextConfig.annotationsInScInitializer=Annotations were found in servlet container initializer. > 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 >Index: java/org/apache/jasper/resources/LocalStrings.properties >=================================================================== >--- java/org/apache/jasper/resources/LocalStrings.properties (revision 1680736) >+++ java/org/apache/jasper/resources/LocalStrings.properties (working copy) >@@ -395,7 +395,7 @@ > jsp.tldCache.tldInDir=TLD files were found in directory [{0}]. > 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. > jsp.tldCache.tldInJar=TLD files were found in JAR [{0}]. >-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. >+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. > > #ELInterpreter > jsp.error.el_interpreter_class.instantiation=Failed to load or instantiate ELInterpreter class [{0}] >Index: java/org/apache/jasper/servlet/TldScanner.java >=================================================================== >--- java/org/apache/jasper/servlet/TldScanner.java (revision 1680736) >+++ java/org/apache/jasper/servlet/TldScanner.java (working copy) >@@ -292,11 +292,12 @@ > class TldScannerCallback implements JarScannerCallback { > private boolean foundJarWithoutTld = false; > private boolean foundFileWithoutTld = false; >- >+ private boolean found = false; >+ > @Override > public void scan(JarURLConnection urlConn, String webappPath, > boolean isWebapp) throws IOException { >- boolean found = false; >+ found = false; > URL jarURL; > try (Jar jar = JarFactory.newInstance(urlConn.getURL())) { > jarURL = jar.getJarFileURL(); >@@ -337,7 +338,7 @@ > if (!metaInf.isDirectory()) { > return; > } >- foundFileWithoutTld = false; >+ found = false; > final Path filePath = file.toPath(); > Files.walkFileTree(metaInf.toPath(), new SimpleFileVisitor<Path>() { > @Override >@@ -349,7 +350,7 @@ > return FileVisitResult.CONTINUE; > } > >- foundFileWithoutTld = true; >+ found = true; > String resourcePath; > if (webappPath == null) { > resourcePath = null; >@@ -372,12 +373,13 @@ > return FileVisitResult.CONTINUE; > } > }); >- if (foundFileWithoutTld) { >+ if (found) { > if (log.isDebugEnabled()) { > log.debug(Localizer.getMessage("jsp.tldCache.tldInDir", > file.getAbsolutePath())); > } > } else { >+ foundFileWithoutTld = true; > if (log.isDebugEnabled()) { > log.debug(Localizer.getMessage("jsp.tldCache.noTldInDir", > file.getAbsolutePath())); >@@ -402,7 +404,7 @@ > > > boolean scanFoundNoTLDs() { >- return foundJarWithoutTld; >+ return foundJarWithoutTld || foundFileWithoutTld; > } > } > } >Index: java/org/apache/tomcat/util/descriptor/web/FragmentJarScannerCallback.java >=================================================================== >--- java/org/apache/tomcat/util/descriptor/web/FragmentJarScannerCallback.java (revision 1680736) >+++ java/org/apache/tomcat/util/descriptor/web/FragmentJarScannerCallback.java (working copy) >@@ -25,7 +25,10 @@ > import java.util.HashMap; > import java.util.Map; > >+import org.apache.juli.logging.Log; >+import org.apache.juli.logging.LogFactory; > import org.apache.tomcat.JarScannerCallback; >+import org.apache.tomcat.util.res.StringManager; > import org.apache.tomcat.util.scan.Jar; > import org.apache.tomcat.util.scan.JarFactory; > import org.xml.sax.InputSource; >@@ -35,6 +38,11 @@ > */ > public class FragmentJarScannerCallback implements JarScannerCallback { > >+ private static final StringManager sm = >+ StringManager.getManager(Constants.PACKAGE_NAME); >+ >+ private static final Log log = LogFactory.getLog(FragmentJarScannerCallback.class); >+ > private static final String FRAGMENT_LOCATION = > "META-INF/web-fragment.xml"; > private final WebXmlParser webXmlParser; >@@ -42,7 +50,10 @@ > private final boolean parseRequired; > private final Map<String,WebXml> fragments = new HashMap<>(); > private boolean ok = true; >- >+ private boolean foundJarWithoutFragments = false; >+ private boolean foundFileWithoutFragments = false; >+ private boolean found = false; >+ > public FragmentJarScannerCallback(WebXmlParser webXmlParser, boolean delegate, > boolean parseRequired) { > this.webXmlParser = webXmlParser; >@@ -54,6 +65,7 @@ > public void scan(JarURLConnection jarConn, String webappPath, boolean isWebapp) > throws IOException { > >+ found = false; > URL url = jarConn.getURL(); > URL resourceURL = jarConn.getJarFileURL(); > Jar jar = null; >@@ -77,6 +89,7 @@ > // distributable > fragment.setDistributable(true); > } else { >+ found = true; > InputSource source = new InputSource( > "jar:" + resourceURL.toString() + "!/" + FRAGMENT_LOCATION); > source.setByteStream(is); >@@ -95,6 +108,16 @@ > fragment.setJarName(extractJarFileName(url)); > fragments.put(fragment.getName(), fragment); > } >+ if(found){ >+ if (log.isDebugEnabled()) { >+ log.debug(sm.getString("fragmentJarScannerCallBack.fragmentInJar", resourceURL.toString())); >+ } >+ }else{ >+ foundJarWithoutFragments = true; >+ if (log.isDebugEnabled()) { >+ log.debug(sm.getString("fragmentJarScannerCallBack.NoFragmentInJar", resourceURL.toString())); >+ } >+ } > } > > private String extractJarFileName(URL input) { >@@ -111,6 +134,7 @@ > @Override > public void scan(File file, String webappPath, boolean isWebapp) throws IOException { > >+ found = false; > WebXml fragment = new WebXml(); > fragment.setWebappJar(isWebapp); > fragment.setDelegate(delegate); >@@ -118,6 +142,7 @@ > File fragmentFile = new File(file, FRAGMENT_LOCATION); > try { > if (fragmentFile.isFile()) { >+ found = true; > try (InputStream stream = new FileInputStream(fragmentFile)) { > InputSource source = > new InputSource(fragmentFile.toURI().toURL().toString()); >@@ -139,6 +164,16 @@ > fragment.setJarName(file.getName()); > fragments.put(fragment.getName(), fragment); > } >+ if(found){ >+ if (log.isDebugEnabled()) { >+ log.debug(sm.getString("fragmentJarScannerCallBack.fragmentInFile", file.getAbsolutePath())); >+ } >+ }else{ >+ foundFileWithoutFragments = true; >+ if (log.isDebugEnabled()) { >+ log.debug(sm.getString("fragmentJarScannerCallBack.NoFragmentInFile", file.getAbsolutePath())); >+ } >+ } > } > > >@@ -156,4 +191,8 @@ > public Map<String,WebXml> getFragments() { > return fragments; > } >+ >+ public boolean scanFoundNoFragments(){ >+ return foundJarWithoutFragments || foundFileWithoutFragments; >+ } > } >Index: java/org/apache/tomcat/util/descriptor/web/LocalStrings.properties >=================================================================== >--- java/org/apache/tomcat/util/descriptor/web/LocalStrings.properties (revision 1680736) >+++ java/org/apache/tomcat/util/descriptor/web/LocalStrings.properties (working copy) >@@ -13,6 +13,10 @@ > # See the License for the specific language governing permissions and > # limitations under the License. > filterDef.invalidFilterName=Invalid <filter-name> [{0}] in filter definition. >+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. >+fragmentJarScannerCallBack.fragmentInJar=Fragments were found in jar [{0}]. >+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. >+fragmentJarScannerCallBack.fragmentInFile=Fragments were found in file [{0}]. > > securityConstraint.uncoveredHttpMethod=For security constraints with URL pattern [{0}] only the HTTP methods [{1}] are covered. All other methods are uncovered. > 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}]
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 56438
:
32639
|
32694
|
32702
|
32719
|
32720
|
32746
|
32747
| 32748