Skip to content

Speeding up Slow Jetty 8 Startups

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=""

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.


Synchronizing Client and Server Side Timeouts

We needed a flashy client-side session timeout warning and chose jQuery Idle Timeout.  We were, however, unhappy with maintaining the timeout value in both the javascript and in web.xml.  The latter is necessary to enforce the session timeout when javascript is off or if tampered with via GreaseMonkey or similar.  We employed a simple strategy to keep things a bit more DRY: generate the javascript timeout value on the serverside via session.getMaxInactiveInterval(), e.g.

<%@ page session="true"%>

<script type="text/javascript">
  // start the jQuery Idle Timeout plugin
  $.idleTimeout('#dialog', 'div.ui-dialog-buttonpane button:first', {
	idleAfter: <%= session.getMaxInactiveInterval() %>, 

This approach is not specific to this jQuery plugin; any client side timeout can use this method. Also, it has the nice quality of respecting any changes made through an application server console, e.g. temporarily overriding the value seeded by in web.xml.