The GlobalNamingResources Component

The GlobalNamingResources element defines the global
JNDI resources for the Server.

These resources are listed in the server's global JNDI resource context.
This context is distinct from the per-web-application JNDI contexts
described in
the JNDI Resources HOW-TO.
The resources defined in this element are not visible in
the per-web-application contexts unless you explicitly link them with
<ResourceLink> elements.

You can configure named values that will be made visible to
web applications as environment entry resources, by nesting
<Environment> entries inside this element. For
example, you can create an environment entry like this:

but does not require modification of the deployment descriptor
to customize this value.

The valid attributes for an <Environment> element
are as follows:

Attribute

Description

description

Optional, human-readable description of this environment entry.

name

The name of the environment entry to be created, relative to the
java:comp/env context.

override

Set this to false if you do not want
an <env-entry> for the same environment entry name,
found in the web application deployment descriptor, to override the
value specified here. By default, overrides are allowed.

type

The fully qualified Java class name expected by the web application
for this environment entry. Must be one of the legal values for
<env-entry-type> in the web application deployment
descriptor: java.lang.Boolean,
java.lang.Byte, java.lang.Character,
java.lang.Double, java.lang.Float,
java.lang.Integer, java.lang.Long,
java.lang.Short, or java.lang.String.

value

The parameter value that will be presented to the application
when requested from the JNDI context. This value must be convertable
to the Java type defined by the type attribute.

You can declare the characteristics of the resource
to be returned for JNDI lookups of <resource-ref> and
<resource-env-ref> elements in the web application
deployment descriptor. You MUST also define
Resource Parameters
for the same resource name, to configure
the object factory to be used (if not known to Tomcat already), and
the properties used to configure that object factory.

but does not require modification of the deployment
descriptor to customize this value.

The valid attriutes for a <Resource> element
are as follows:

Attribute

Description

auth

Specify whether the web Application code signs on to the
corresponding resource manager programatically, or whether the
Container will sign on to the resource manager on behalf of the
application. The value of this attribute must be
Application or Container. This
attribute is required if the web application
will use a <resource-ref> element in the web
application deployment descriptor, but is optional if the
application uses a <resource-env-ref> instead.

description

Optional, human-readable description of this resource.

name

The name of the resource to be created, relative to the
java:comp/env context.

scope

Specify whether connections obtained through this resource
manager can be shared. The value of this attribute must be
Shareable or Unshareable. By default,
connections are assumed to be shareable.

type

The fully qualified Java class name expected by the web
application when it performs a lookup for this resource.

This element is used to configure the resource manager (or object
factory) used to return objects when the web application performs a
JNDI lookup operation on the corresponding resource name. You
MUST define resource parameters for every resource name
that is specified by a <Resource> element inside a
<Context> or <DefaultContext>
element in $CATALINA_HOME/conf/server.xml, and/or for every
name declared in a <resource-ref> or
<resource-env-ref> element in the web application
deployment descriptor, before that resource can be successfully
accessed.

Resource parameters are defined by name, and the precise set of
parameter names supported depend on the resource manager (or object
factory) you are using - they must match the names of settable JavaBeans
properties on the corresponding factory class. The JNDI implementation
will configure an instance of the specified factory class specified by
calling all the corresponding JavaBeans property setters, and then
making the factory instance available via the JNDI lookup()
call.

The resource parameters for a JDBC data source might look something
like this:

If you need to specify the Java class name of a factory class for a
particular resource type, use a <parameter> entry
named factory nested inside the
<ResourceParams> element.

The valid attributes of a <ResourceParams> element
are as follows:

Attribute

Description

name

The name of the resource being configured, relative to the
java:comp/env contxt. This name MUST
match the name of a resource defined by a <Resource>
element in $CATALINA_HOME/conf/server.xml, and/or
referenced in a <resource-ref> or
<resource-env-ref> element in the web application
deployment descriptor.