Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Correction: TLD scanning does occur at startup. I was confused that there are two TLD scans and the first one happens silently.

...

It is possible to configure a web application to omit most of the scanning. It is also possible to configure which JARs Tomcat should skip in its scanning.

Other features that require scanning are:

  • Discovery of tag libraries — scanning for Tag Library Descriptor files (META-INF/**/*.tld) (shortened as TLD scanning)

The TLD scanning is done at startup, because a library can define a Listener in its TLD file.

A note: in Tomcat 7 and earlier the TLD scanning happens twice, (1) by servlet engine to discover the listeners, (2) by JSP engine when compiling a JSP page. The first scanning happens at startup time (in TldConfig), the second one happens when Tomcat needs to compile a JSP page . It does not affect the startup time, but does affect the access time for the first not-yet-compiled JSP page in the web application(in TldLocationsCache). The second scanning is more noticeable, because it prints a diagnostic message about scanned JARs that contained no TLDs. In Tomcat 8 the TLD scanning happens only once at startup time (in JasperInitializer).

Remove unnecessary JARs

Remove any JAR files you do not need. When searching for classes every JAR file needs to be examined to find the needed class. If the jar file is not there - there is nothing to search.

...

  1. metadata-complete="true" attribute on the <web-app> element. 2. an empty <absolute-ordering /> element.

"Setting metadata-complete="true"" disables scanning your web application and its libraries for classes that use annotations to define components of a web application (Servlets etc.).

The metadata-complete This option is not enough to disable all of annotation scanning. If there is a SCI with a @HandlesTypes HandlesTypes annotation, Tomcat has to scan your application for classes that use annotations or interfaces specified in that @HandlesTypes annotation and provide the list of such classes to the SCI.

An example of such SCI is in the WebSocket API implementation jar (tomcat-websocket.jar, tomcat7-websocket.jar) which is included with Tomcat 7 starting with 7.0.47.

The "<absolute-ordering>" element specifies which web fragment JARs (according to the names in their WEB-INF/web-fragment.xml files) have to be scanned for SCIs, fragments and annotations. If you specify an An empty "<absolute-ordering/>" it means that none of that scanning will occur. This feature does not affect scanning for web application resources element configures that none are to be scanned.

Note: in Tomcat 8 the container-provided SCIs are always discovered, regardless of absolute-ordering.

An example of a SCI is in the WebSocket API implementation jar (tomcat-websocket.jar, tomcat7-websocket.jar) which is included with Tomcat 7 starting with 7.0.47.

Scanning for web application resources and TLD scanning are not affected by these options.

Exclude JARs from scanning

...