Is it possible to turn off taglib scanning in Tomcat?

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.


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


On Tomcat 8 it can be solved by adding the META-INF\context.xml 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