Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "Jetty/Reference/jetty-env.xml"
(New page: {{Jetty Reference | introduction = <tt>jetty-env.xml</tt> is an optional Jetty configuration file which configures webapp-specific JNDI resources. The format of <tt>jetty-web.xml</tt> is t...) |
m |
||
(11 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{Jetty Reference | {{Jetty Reference | ||
− | | introduction = <tt>jetty-env.xml</tt> is an optional Jetty | + | | introduction = <tt>jetty-env.xml</tt> is an optional Jetty file that configures JNDI resources for an individual webapp. The format of <tt>jetty-web.xml</tt> is the same as <tt>[[Jetty/Reference/jetty.xml|jetty.xml]]</tt>–it is an XML mapping of the Jetty API. |
− | + | ||
− | + | ||
| body = | | body = | ||
+ | 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. You define global naming resources on the server via <tt>jetty.xml</tt>. | ||
== Root Element == | == Root Element == | ||
− | <tt>jetty-env.xml</tt> | + | Jetty applies <tt>jetty-env.xml</tt> on a per-webapp basis, and configures an instance of org.eclipse.jetty.webapp.WebAppContext. |
− | + | ||
<source lang="xml"> | <source lang="xml"> | ||
<?xml version="1.0" encoding="ISO-8859-1"?> | <?xml version="1.0" encoding="ISO-8859-1"?> | ||
Line 18: | Line 16: | ||
</source> | </source> | ||
− | {{ | + | {{caution|Make sure you are applying the configuration to an instance of the proper class.|<tt>jetty-env.xml</tt> configures an instance of WebAppContext, and not an instance of Server.}} |
== Using <tt>jetty-env.xml</tt> == | == Using <tt>jetty-env.xml</tt> == | ||
− | Place the <tt>jetty-env.xml</tt> file | + | Place the <tt>jetty-env.xml</tt> file in your web application's WEB-INF folder. |
− | + | == Example == | |
− | <!-- | + | <source lang="xml"> |
− | == | + | <?xml version="1.0"?> |
− | --> | + | <!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd"> |
+ | |||
+ | <Configure class="org.eclipse.jetty.webapp.WebAppContext"> | ||
+ | |||
+ | <!-- Add an EnvEntry only valid for this webapp --> | ||
+ | <New id="gargle" class="org.eclipse.jetty.plus.jndi.EnvEntry"> | ||
+ | <Arg>gargle</Arg> | ||
+ | <Arg type="java.lang.Double">100</Arg> | ||
+ | <Arg type="boolean">true</Arg> | ||
+ | </New> | ||
+ | |||
+ | <!-- Add an override for a global EnvEntry --> | ||
+ | <New id="wiggle" class="org.eclipse.jetty.plus.jndi.EnvEntry"> | ||
+ | <Arg>wiggle</Arg> | ||
+ | <Arg type="java.lang.Double">55.0</Arg> | ||
+ | <Arg type="boolean">true</Arg> | ||
+ | </New> | ||
+ | |||
+ | <!-- an XADataSource --> | ||
+ | <New id="mydatasource99" class="org.eclipse.jetty.plus.jndi.Resource"> | ||
+ | <Arg>jdbc/mydatasource99</Arg> | ||
+ | <Arg> | ||
+ | <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> | ||
+ | </New> | ||
+ | </Arg> | ||
+ | </New> | ||
+ | </Configure> | ||
+ | </source> | ||
| more = | | more = | ||
− | * [[Jetty/ | + | * [[Jetty/Reference/jetty.xml syntax|jetty.xml Syntax Reference]]–in-depth reference for Jetty-specific configuration XML syntax |
− | * [[Jetty/ | + | * [[Jetty/Reference/jetty.xml|jetty.xml]]–configuration file for configuring the entire server |
− | + | ||
}} | }} |
Latest revision as of 14:49, 20 August 2010
Introduction
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" "http://www.eclipse.org/jetty/configure.dtd"> <Configure class="org.eclipse.jetty.webapp.WebAppContext"> .. </Configure>
Using jetty-env.xml
Place the jetty-env.xml file in your web application's WEB-INF folder.
Example
<?xml version="1.0"?> <!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd"> <Configure class="org.eclipse.jetty.webapp.WebAppContext"> <!-- Add an EnvEntry only valid for this webapp --> <New id="gargle" class="org.eclipse.jetty.plus.jndi.EnvEntry"> <Arg>gargle</Arg> <Arg type="java.lang.Double">100</Arg> <Arg type="boolean">true</Arg> </New> <!-- Add an override for a global EnvEntry --> <New id="wiggle" class="org.eclipse.jetty.plus.jndi.EnvEntry"> <Arg>wiggle</Arg> <Arg type="java.lang.Double">55.0</Arg> <Arg type="boolean">true</Arg> </New> <!-- an XADataSource --> <New id="mydatasource99" class="org.eclipse.jetty.plus.jndi.Resource"> <Arg>jdbc/mydatasource99</Arg> <Arg> <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> </New> </Arg> </New> </Configure>
Additional Resources
- jetty.xml Syntax Reference–in-depth reference for Jetty-specific configuration XML syntax
- jetty.xml–configuration file for configuring the entire server