Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to turn off taglib scanning in Tomcat?

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?

like image 213
Matt Passell Avatar asked Sep 28 '09 22:09

Matt Passell


2 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.

like image 65
ZZ Coder Avatar answered Nov 23 '22 16:11

ZZ Coder


Since 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

like image 30
Sergey Avatar answered Nov 23 '22 16:11

Sergey