Place the <tt>jetty-env.xml</tt> file into your web application's WEB-INF folder. When Jetty deploys a web application, it automatically looks for a file called <tt>WEB-INF/jetty-env.xml</tt> within the web application (or WAR), and sets up the webapp naming environment so that naming references in the <tt>WEB-INF/web.xml</tt> file can be resolved from the information provided in the <tt>WEB-INF/jetty-env.xml</tt> and <tt>[[Jetty/Reference/jetty.xml|jetty.xml]]</tt> files.

+

Place the <tt>jetty-env.xml</tt> file into your web application's WEB-INF folder. When Jetty deploys a web application, it automatically looks for a file called <tt>WEB-INF/jetty-env.xml</tt> within the web application (or WAR), and sets up the webapp naming environment so that naming references in the <tt>WEB-INF/web.xml</tt> file can be resolved from the information provided in the <tt>WEB-INF/jetty-env.xml</tt> and [[Jetty/Reference/jetty.xml|jetty.xml]] files.

<tt>jetty-env.xml</tt> files contain configuration specific to a webapp. Global naming resources should be defined on the server via <tt>jetty.xml</tt>.

<tt>jetty-env.xml</tt> files contain configuration specific to a webapp. Global naming resources should be defined on the server via <tt>jetty.xml</tt>.

Revision as of 13:27, 19 August 2010

Contents

Introduction

jetty-env.xml is an optional Jetty configuration file that you can place in your webapp's WEB-INF directory to configure JNDI resources specifically for that webapp. The format of jetty-web.xml is the same as jetty.xml -- it is an XML mapping of the Jetty API.

This document offers an overview for using the jetty-env.xml configuration file. For a more in-depth look at the syntax, see jetty.xml Syntax Reference.

At startup, Jetty will automatically look for a file of this name in the webapp's WEB-INF directory, and set up the webapp's naming environment so that naming references in the WEB-INF/web.xml file can be resolved from the information in the WEB-INF/jetty-env.xml file (along with any global naming resources defined in a jetty.xml startup file.

Root Element

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

Make sure you are applying the configuration to an instance of the proper classjetty-env.xml configures an instance of WebAppContext, and not an instance of Server

Using jetty-env.xml

Place the jetty-env.xml file into your web application's WEB-INF folder. 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.

jetty-env.xml files contain configuration specific to a webapp. Global naming resources should be defined on the server via jetty.xml.

Example

<?xmlversion="1.0"?><!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd"><Configureclass="org.eclipse.jetty.webapp.WebAppContext"><!-- Add an EnvEntry only valid for this webapp --><Newid="gargle"class="org.eclipse.jetty.plus.jndi.EnvEntry"><Arg>gargle</Arg><Argtype="java.lang.Double">100</Arg><Argtype="boolean">true</Arg></New><!-- Add an override for a global EnvEntry --><Newid="wiggle"class="org.eclipse.jetty.plus.jndi.EnvEntry"><Arg>wiggle</Arg><Argtype="java.lang.Double">55.0</Arg><Argtype="boolean">true</Arg></New><!-- an XADataSource --><Newid="mydatasource99"class="org.eclipse.jetty.plus.jndi.Resource"><Arg>jdbc/mydatasource99</Arg><Arg><Newclass="com.atomikos.jdbc.SimpleDataSourceBean"><Setname="xaDataSourceClassName">org.apache.derby.jdbc.EmbeddedXADataSource</Set><Setname="xaDataSourceProperties">databaseName=testdb99;createDatabase=create</Set><Setname="UniqueResourceName">mydatasource99</Set></New></Arg></New></Configure>