Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: for the plan.

Jump to: navigation, search



Jetty 7 and Jetty 8 are now EOL (End of Life)


All development and stable releases are being performed with Jetty 9 and Jetty 10.

This wiki is now officially out of date and all content has been moved to the Jetty Documentation Hub

Direct Link to updated documentation:

To deploy a web application or WAR into different environments, most likely you will need to customize the webapp for compatibility with each environment. The challenge is to do so without changing the webapp itself. You can use a jetty.xml file for some of this work since it is not part of the webapp. But there are some changes that jetty.xml cannot accomplish, for example, modifications to servlet init-params and context init-params. Using webdefault.xml is not an option because Jetty applies webdefault.xml to a web application before the application's own WEB-INF/web.xml, which means that it cannot override values inside the webapp's web.xml.

The solution is override-web.xml. It is a web.xml file that Jetty applies to a web application after the application's own WEB-INF/web.xml, which means that it can override values or add new elements. You define it per-webapp, using the web.xml syntax.

Using override-web.xml

You can specify the override-web.xml to use for an individual web application, in that webapp's jetty-web.xml.

<Configure class="org.eclipse.jetty.webapp.WebAppContext">
  <!-- Set up the path to the custom override descriptor, 
  relative to your $(jetty.home) directory or to the current directory -->
  <Set name="overrideDescriptor"><SystemProperty name="jetty.home" default="."/>/my/path/to/override-web.xml</Set>

The equivalent in code is:

import org.eclipse.jetty.webapp.WebAppContext;
    WebAppContext wac = new WebAppContext();
    //Set the path to the override descriptor, based on your $(jetty.home) directory

Alternatively, use the classloader to get the path to the override descriptor as a resource.

Using the Jetty Maven Plugin

Use the <overrideDescriptor> tag as follows:


Additional Resources

Copyright © Eclipse Foundation, Inc. All Rights Reserved.