Appendix A.3.4 Learning about jetty-env.xml

A jetty-env.xml file is an optional file that you can place in your webapp’s WEB-INF directory to configure JNDI resources specifically for that webapp.

The syntax of the file is the same as for the jetty-web.xml file.

At startup, Jetty automatically looks 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.

Example:

<?xml version="1.0"?>

<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//
DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">

<Configure class="org.mortbay.jetty.webapp.WebAppContext">

  <!-- Add an EnvEntry only valid for this webapp -->

  <New id="gargle"     class="org.mortbay.jetty.plus.naming.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.mortbay.jetty.plus.naming.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.mortbay.jetty.plus.naming.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>

There is more information and examples in the section on JNDI.


  • Currently 3.02/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
  Flag Inappropriate Content 0 comments