Reputation: 4749
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?
Upvotes: 8
Views: 17601
Reputation: 3721
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
Upvotes: 13
Reputation: 459
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
Upvotes: 10
Reputation: 1346
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".
Upvotes: 1
Reputation: 75456
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.
Upvotes: 14