Skip to main content
Jump to: navigation, search

Jetty/Howto/Avoid slow deployment

< Jetty‎ | Howto


Annotations and annotation scanning was added to servlet specification 2.5. Since that time, there has been the possibility that your webapp will need to have all of its classes scanned at deployment to find annotations. The attribute metadata-complete was added in order to prevent unnecessary scanning. If you do not set metadata-complete=true, you risk slow deployment due to annotation scanning. If you have a large number of jars in your webapp, this can be very time consuming.

Since servlet 3.0 (supported by jetty-8.x), there has been the added requirement that both container and webapp jars can be scanned. In fact, even if you do set metadata-complete=true in your web.xml, scanning will probably still occur, due to the requirement to support the new ServletContainerInitializers. See

This being the case, it is important that you control which jars are scanned in order to cut down deployment time.


Jetty allows for the configuration of 2 different context attributes that control which jars are scanned. One controls which container jars are scanned, and the other controls which webapp jars are scanned:

  • org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern. The primary use for this attribute is to control which jars are scanned for tlds in jetty-7. You can find information on which jars to include here: Configuring JSP. In jetty-8, tlds are found via other means and thus this attribute has less importance. Note that if this attribute is *not* set, *no* container jars are scanned. You must set it if you want particular jars scanned.
  • org.eclipse.jetty.server.webapp.WebInfIncludeJarPattern. By default, if this attribute is not set, all jars in WEB-INF/lib will be scanned. You can selectively include jars to be scanned by defining a series of patterns. For example, given this listing of files in WEB-INF/lib:

<Configure class="org.eclipse.jetty.webapp.WebAppContext">
    <Call name="setAttribute">

Then the following files would match and be scanned:


Patterns are specified using java regex expressions.

Context attributes can be set for a single webapp:

Context attributes can be set for multiple webapps by configuring the Deployment Manager.

Back to the top