Analysis and Optimization Strategies for Tomcat TLD Scanning Warnings

Nov 24, 2025 · Programming · 8 views · 7.8

Keywords: Tomcat | TLD Scanning | Performance Optimization | Eclipse Configuration | JSP Compilation

Abstract: This paper provides an in-depth analysis of the 'At least one JAR was scanned for TLDs yet contained no TLDs' warning in Tomcat servers. Through detailed configuration of logging.properties and catalina.properties files, it demonstrates how to enable debug logging to identify JAR files without TLDs and offers specific methods to optimize startup time and JSP compilation performance. The article combines practical configuration steps in the Eclipse development environment to provide developers with a comprehensive troubleshooting guide.

Problem Background and Phenomenon Analysis

In Tomcat 7.30 and later versions, developers frequently encounter the following warning message in the console or log files: 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. This warning indicates that Tomcat has scanned certain JAR files for Tag Library Descriptors (TLDs) during startup or JSP compilation, but these JAR files do not contain any TLD definitions.

Debug Configuration and Logging Enablement

To view which specific JAR files were scanned but contained no TLDs, it is necessary to enable debug-level logging in Tomcat. In the Eclipse integrated development environment, standard modifications to the conf\logging.properties file may not take effect because Eclipse uses its own launch configuration.

First, copy the logging.properties file to the Eclipse server configuration directory: Servers\Tomcat v7.0 Server at localhost-config\. Then uncomment and ensure the following line exists in this file:

org.apache.jasper.compiler.TldLocationsCache.level = FINE

Next, open the server's launch configuration in Eclipse and add the following to the VM arguments section:

-Djava.util.logging.config.file="${workspace_loc}\Servers\Tomcat v7.0 Server at localhost-config\logging.properties" -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager

After restarting the Tomcat server, the console will display detailed debug information, for example: FINE: No TLD files were found in [file:/C:/Dropbox/eclipse_workspaces/javaEE/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/ted2012/WEB-INF/lib/logback-classic-1.0.7.jar]. Consider adding the JAR to the tomcat.util.scan.DefaultJarScanner.jarsToSkip or org.apache.catalina.startup.TldConfig.jarsToSkip property in CATALINA_BASE/conf/catalina.properties file.

Performance Optimization and Warning Elimination

After identifying JAR files without TLDs, you can skip scanning these JARs by modifying the catalina.properties file, thereby improving startup performance and eliminating warnings. Add the JAR file names to be skipped to the org.apache.catalina.startup.TldConfig.jarsToSkip property:

org.apache.catalina.startup.TldConfig.jarsToSkip=logback-classic-1.0.7.jar,
joda-time-2.1.jar,joda-time-2.1-javadoc.jar,mysql-connector-java-5.1.24-bin.jar,
logback-core-1.0.7.jar,javax.servlet.jsp.jstl-api-1.2.1.jar

This configuration can significantly reduce unnecessary file scanning operations, with particularly noticeable effects in large web applications containing numerous third-party libraries.

Technical Principles Deep Analysis

Tomcat's TLD scanning mechanism is an important component of the JSP compilation process. When the server starts or JSP pages are modified, Tomcat automatically scans all JAR files in the WEB-INF/lib directory, looking for .tld files in the META-INF directory. These TLD files define the behavior and attributes of custom tag libraries.

However, many common third-party libraries (such as logging frameworks, database drivers, etc.) do not contain any TLD definitions. Each scan of these TLD-free JAR files consumes system resources, and this overhead becomes particularly significant in development environments where servers are frequently restarted.

Starting from Tomcat 7, a more granular JAR scanning control mechanism was introduced. tomcat.util.scan.DefaultJarScanner and org.apache.catalina.startup.TldConfig provide the ability to skip scanning of specific JARs. By properly configuring the jarsToSkip property, developers can precisely control which JAR files should be excluded from TLD scanning.

Practical Recommendations and Best Practices

In actual development practice, it is recommended to adopt a systematic approach to handling TLD scanning issues. First, enable debug logging in the production environment to identify all JAR files that are scanned but contain no TLDs. Then update the catalina.properties configuration based on the identification results.

For team development projects, the optimized catalina.properties file should be included in the version control system to ensure all development team members can benefit from the performance optimization. Additionally, regularly review project dependencies and remove unused library files to fundamentally reduce the number of JARs that need to be scanned.

In continuous integration environments, consider writing automated scripts to analyze build artifacts and automatically generate optimized jarsToSkip configurations, ensuring optimal performance with each build.

Copyright Notice: All rights in this article are reserved by the operators of DevGex. Reasonable sharing and citation are welcome; any reproduction, excerpting, or re-publication without prior permission is prohibited.