Chapter 11 Configuring JNDI Resources

Tomcat 6 provides an implementation of a JNDI InitialContext implementation instance for each web application. J2EE includes a standard set of elements in the /WEB-INF/web.xml file to reference resources.

Entries of per-web-application InitialContext are configured in the <Context> elements. You may specify these configurations in either $CATALINA_HOME/conf/server.xml or the per-web-application context XML file.

Tomcat 6 provides and maintains a separate namespace of global resources for the entire server, which can be configured in the <GlobalNamingResources> element of $CATALINA_HOME/conf/server.xml. Use <ResourceLink> elements to expose the resources to web applications.

The following elements in the web application deployment descriptor may reference the resources:

  • <env-entry> Environment entry – You can use this single-value parameter to configure how an application operates.
  • <resource-ref> Resource reference – This is an object factory for resources.
  • <resource-env-ref> Resource environment reference – This is a new variation of resource-ref added in Servlet 2.4.

When you initially deploy a web application, the InitialContext is configured and made available to web application components.

Configuring JNDI Resources

Available JNDI Resources are configured based on the inclusion of the listed elements in the or elements:

  • <Environment> – This configures names and values for scalar environment entries.
  • <Resource> – This configures the name and data type of a resource made available to the application.
  • <ResourceLink> – This adds a link to a resource defined in the global JNDI context.
  • <Transaction> – This adds a resource factory for instantiating the UserTransaction object instance.

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