On startup, Tomcat recursively scans the WEB-INF directories for TLD (Tag Library Descriptor) files. As a result, if a webapp has a lot of files under that directory, it slows down the startup process. Does anyone know if there is a way in that situation to turn off scanning completely, or at least provide a filter to narrow the search?
-
Is there a way to assign just the specific jars you want to scan? – Nov 09 '11 at 21:36
-
But if you remove some jars, they will not be computed correctly, will they? – Aerox May 29 '20 at 16:31
-
@Aerox I don't quite understand your question? Were you meaning to point out that if you do this, no tag library descriptors will be found? If so, that wasn't (and still isn't) a problem for my case because I wasn't using JSPs. – Matt Passell May 30 '20 at 21:44
-
I was assuming you used JSP pages, so I said that if you turn off scanning completely I suppose you can't build it if requires some specific JARs to proceed with a clean Startup. If you weren't using JARs, probably it's not the case, is it? – Aerox Jun 05 '20 at 08:07
4 Answers
You can add processTlds attributes in the context,
<Context processTlds="false" ... />
However, your TLDs defined in the JAR file wouldn't work without scanning the JARs. You have to define all TLDs in WEB-INF.

- 74,484
- 29
- 137
- 169
-
-
Do you know why I get this error? "Setting property 'processTlds' to 'false' did not find a matching property." Is it because I added the property in the global Tomcat /conf/context.xml ? – Sorin Postelnicu Jan 12 '21 at 14:23
-
The same message ('no matching property') appears even after I removed the property from /conf/context.xml and added it to META-INF/context.xml. Is this property not supported in Tomcat 8.5 ? – Sorin Postelnicu Jan 12 '21 at 22:23
Since Tomcat 8 it can be solved by adding the META-INF/context.xml
file with the configuration seen below to your WAR file.
No need to change the global Tomcat configuration.
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<JarScanner>
<JarScanFilter tldSkip="*.*"/>
</JarScanner>
</Context>
The relevant documentation is available here: http://tomcat.apache.org/tomcat-8.0-doc/config/jar-scan-filter.html

- 3,253
- 2
- 33
- 55
I was puzzled by the same problem. Looking into source code of Tomcat 7.0.40, it is not possible to avoid jars scanning by setting 'processTlds=false', they will still be scanned for web fragments (ContextConfig.processJarsForWebFragments()).
There are 2 options remaining:
Set property in TOMCAT_HOME/conf/catalina.properties
org.apache.catalina.startup.ContextConfig.jarsToSkip=*.jar
Replace StandardJarScanner by your own implementation, for example empty one and refer to it from my.war/META-INF/context.xml:
<Context processTlds="false">
<JarScanner className="org.my.tomcat.NullJarScanner"/>
</Context>
In latter case you'll need to make sure that NullJarScanner class is available in tomcat's lib directory, not your .war

- 459
- 1
- 7
- 18
As an alternative (if you still prefer to scan some JARs) you could append new values to "tomcat.util.scan.DefaultJarScanner.jarsToSkip" property in "{TOMCAT_HOME}/conf/catalina.properties".

- 1,346
- 9
- 15
-
That's new in Tomcat 7, right? In my case, I'm still on Tomcat 6, but for Tomcat 7 users that looks like a good option. – Matt Passell Apr 13 '12 at 13:52
-
Yes. Not applicable to Tomcat 6. Property appears in Tomcat 7. – Vadim Ponomarev Apr 13 '12 at 14:18