This troubleshooting guide aims to help developers understand the issue of "At least one JAR was scanned for TLDs yet contained no TLDs" and provide step-by-step solutions to fix it. We will discuss the common causes of this issue and provide a detailed guide to resolve it.
Table of Contents
When deploying a Java web application, you might encounter the following warning message:
WARNING: 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.
This warning is usually encountered when using a web server like Tomcat or Jetty. It occurs when the server scans JAR files for TLD (Tag Library Descriptor) files but does not find any. Although this warning does not cause any functional issues in the application, it may clutter the logs and slow down the startup process.
Causes of the Issue
The main cause of this issue is the presence of JAR files that do not contain any TLD files in the classpath. These JAR files are scanned by the server, but since they do not have any TLDs, the warning is generated. The server scans for TLD files to load tag libraries used in JSP (JavaServer Pages) files.
To resolve this issue, follow the steps below:
Enable Debug Logging: To identify the JAR files causing the warning, enable debug logging for the
org.apache.jasper.servlet.TldScanner logger. In the
logging.properties file, add the following line:
org.apache.jasper.servlet.TldScanner.level = FINE
This will display the list of JAR files scanned but did not contain any TLDs in the logs.
Identify JAR Files Without TLDs: Review the logs and take note of the JAR files that do not contain any TLDs. You will see log entries like:
FINE: No TLD files were found in [...].jar. Consider adding the [...] JAR to the [...] attribute in your web application.
Exclude JAR Files from Scanning: Update the
web.xml file in your web application to exclude the identified JAR files from being scanned for TLDs. Add the following lines to the
<context-param> <param-name>org.apache.jasper.servlet.JspServlet.params.tldSkip</param-name> <param-value>[...].jar,[...].jar</param-value> </context-param>
[...].jar with the names of the JAR files identified in step 2. Separate multiple JAR file names with commas.
- Restart the Web Application: Finally, restart your web application to apply the changes made in the
web.xmlfile. The warning should no longer appear in the logs.
1. What is a TLD file?
A TLD (Tag Library Descriptor) file is an XML document that describes a set of custom tags used in JSP (JavaServer Pages) files. It provides information about the tag library, such as the library's URI, version, and the custom tags it contains.
2. How does the server scan for TLD files?
The server scans for TLD files during the web application's startup process. It searches for TLD files in the
WEB-INF directory, as well as in the JAR files present in the application's classpath.
3. Can I ignore this warning?
Yes, you can ignore this warning if it does not cause any functional issues in your application. However, it is recommended to address the issue to keep the logs clean and improve the startup process's performance.
4. Will excluding JAR files from scanning affect the functionality of the web application?
No, excluding JAR files without TLDs from scanning will not affect the functionality of the web application. The server scans JAR files for TLD files to load tag libraries used in JSP files. If a JAR file does not contain any TLDs, it does not contribute to the functionality of the JSP files.
5. Can I exclude all JAR files from scanning?
Excluding all JAR files from scanning is not recommended, as this may prevent the server from loading necessary tag libraries used in JSP files. It is best to exclude only JAR files that do not contain any TLDs, as identified in the debug logs.