<env-entry/> <resource-ref/> <resource-env-ref/>
Configuring env-entrys shows you how to set up overrides for
<env-entry> elements in web.xml. Configuring resource-refs and resource-env-refs discusses how to configure support resources such as
Furthermore, it is possible to plug a JTA
javax.transaction.UserTransaction implementation into Jetty so that webapps can lookup
java:comp/UserTransaction to obtain a distributed transaction manager. See Configuring XA Transactions.
You can define your naming resources with 3 scopes:
- jvm scope - the name is unique within the jvm
- server scope - the name is unique to the Server instance
- webapp scope - the name is unique to the WebAppContext instance
The section Global or scoped to a webapp explains what scoping is, and shows you how to use it. Essentially, scoping ensures that JNDI bindings from one webapp do not interfere with the JNDI bindings of another - unless of course you wish them to.
"org.mortbay.naming.plus.Resource"for all other type of resources
"org.mortbay.plus.naming.Transaction"for a JTA manager. We'll take a closer look at this in the Configuring XA Transactions section.
"org.mortbay.plus.naming.Link"for link between a web.xml resource name and a NamingEntry. See Configuring Links for more info.
There are 3 places in which you can define naming entries:
This example will define a virtual
mySpecialValue with value
4000 that is unique within the whole jvm. It will be put into JNDI at
java:comp/env/mySpecialValue for every webapp deployed. Moreover, the boolean argument indicates that this value should override an
env-entry of the same name in web.xml. If you don't want to override, then omit this argument or set it to
See Global or scoped to a webapp for more information on other scopes.
- run "mvn clean install" to build it
- then edit contexts/test-jndi.xml and uncomment one of the transaction manager setups
- then edit contexts/test-jndi.d/WEB-INF/jetty-env.xml and uncomment one of the transaction manager setups
- copy a derby.jar to the jetty lib/ directory, as well as copy all the necessary jars for the flavour of transaction manager you are using. There are instructions for some of the popular transaction managers on the wiki at JNDI
You run the demo like so: