Jetty has moved!
Jetty is a project at the Eclipse Foundation.
Homepage:http://www.eclipse.org/jetty
Downloads: http://download.eclipse.org/jetty/
Documentation:http://www.eclipse.org/jetty/documentation/current/
About:http://www.eclipse.org/jetty/about.php
Jetty Powered:http://www.eclipse.org/jetty/powered/
Contact the core Jetty developers at www.webtide.com
private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ... scalability guidance for your apps and Ajax/Comet projects ... development services from 1 day to full product delivery
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Next »

Using JNDI Resources with jetty6

Jetty6 supports java:comp/env lookups. This is an optional feature provided by the 2 jars lib/naming/jetty-naming.jar and lib/plus/jetty-plus.jar. As it is an optional feature, some setup needs to be done.

Firstly, to enable JNDI for a web application, you need to configure the WebAppContext to parse the web.xml file and perform the java:comp/env linkages. The class that does this is org.mortbay.jetty.plus.webapp.Configuration, and we specify its name in the list of configurations to be applied to the webapp. The following example enables JNDI for the testWebAppContext:

Then, you may configure container-wide naming resources that can be referenced in a web.xml file and accessed from within the java:comp/env naming environment of the webapp during execution. Specifically, you may configure support for the following web.xml elements:

Configuring resource-refs and resource-env-refs discusses how to configure support resources such as javax.sql.DataSource}}s. You can also configure global env-entry elements that can override the {{<env-entry> settings in a web.xml file. See Configuring global env-entrys.

Furthermore, it is possible to plug a JTA javax.transaction.UserTransaction implementation into Jetty so that webapps can lookup java:comp/UserTransaction. See Configuring Transactions.

Configuring global env-entrys

Sometimes it is useful to be able to pass configuration information to a webapp at runtime that either cannot be or is not convient to be coded into a web.xml env-entry. In this case, you can use {{org.mortbay.jetty.plus.naming.EnvEntry}}s in the jetty.xml file and configure them to override an entry of the same name in web.xml.

This example will define an <env-entry> called mySpecialValue with value 4000 that will be put into JNDI at java:comp/env/mySpecialValue for every webapp. 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 false.

Configuring resource-refs and resource-env-refs

Configuring Transactions

  • No labels
Contact the core Jetty developers at www.webtide.com
private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ... scalability guidance for your apps and Ajax/Comet projects ... development services from 1 day to full product delivery