Skip to content

Speeding up Slow Jetty 8 Startups

March 10, 2012

A few weeks ago our Jetty startup time went from 8 seconds to over 60. We discovered it was searching every class in every jar in WEB-INF/lib and WEB-INF/classes for the JEE annotations, e.g. annotations such as @WebFilter which replace fragments inside the web.xml file. This is normal behavior, according to many sources, and no fault of Jetty’s. However, a quick search for javax.servlet.annotation showed that we were not using any of these. Adding ‘metadata-complete=”true”‘ to our web.xml’s web-app restored our startup time to 8 seconds.

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
         metadata-complete="true"
         version="3.0">

This attribute tells the container that the web.xml contains the complete configuration. I think this is a fairly well-known topic, but worth (re)posting if it saves someone else some time.

About these ads

From → Uncategorized

3 Comments
  1. Thanks, this was very useful.

  2. Rafael Rocha permalink

    Thanx man really usefull!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.