Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: for the plan.

Jump to: navigation, search



jetty-env.xml is an optional Jetty file that configures JNDI resources for an individual webapp. The format of jetty-web.xml is the same as jetty.xml–it is an XML mapping of the Jetty API.

When Jetty deploys a web application, it automatically looks for a file called WEB-INF/jetty-env.xml within the web application (or WAR), and sets up the webapp naming environment so that naming references in the WEB-INF/web.xml file can be resolved from the information provided in the WEB-INF/jetty-env.xml and jetty.xml files. You define global naming resources on the server via jetty.xml.

Root Element

Jetty applies jetty-env.xml on a per-webapp basis, and configures an instance of org.eclipse.jetty.webapp.WebAppContext.

<?xml version="1.0"  encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
Make sure you are applying the configuration to an instance of the proper class.
jetty-env.xml configures an instance of WebAppContext, and not an instance of Server.

Using jetty-env.xml

Place the jetty-env.xml file in your web application's WEB-INF folder.


 <?xml version="1.0"?>
 <!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "">
 <Configure class="org.eclipse.jetty.webapp.WebAppContext">
   <!-- Add an EnvEntry only valid for this webapp               -->
   <New id="gargle"  class="">
     <Arg type="java.lang.Double">100</Arg>
     <Arg type="boolean">true</Arg>
  <!-- Add an override for a global EnvEntry                           -->
   <New id="wiggle"  class="">
     <Arg type="java.lang.Double">55.0</Arg>
     <Arg type="boolean">true</Arg>
   <!-- an XADataSource                                                -->
   <New id="mydatasource99" class="">
       <New class="com.atomikos.jdbc.SimpleDataSourceBean">
         <Set name="xaDataSourceClassName">org.apache.derby.jdbc.EmbeddedXADataSource</Set>
         <Set name="xaDataSourceProperties">databaseName=testdb99;createDatabase=create</Set>
         <Set name="UniqueResourceName">mydatasource99</Set>

Additional Resources

Copyright © Eclipse Foundation, Inc. All Rights Reserved.