Download
FAQ
History
PrevHomeNext API
Search
Feedback
Divider

Configuring Resources

The Resources node represents the Global Naming Resources component. The elements under this node represent the global JNDI resources which are defined for the Server. The following resources can be used to configure the resource manager (or object factory) used to return objects when a Web application performs a JNDI lookup operation on the corresponding resource name:

For more information on configuring Global Naming Resources, read the document titled GlobalNamingResources Component, available from http://jakarta.apache.org/tomcat/tomcat-5.0-doc/config/globalresources.html.

Configuring Data Sources

Many Web applications need to access a database via a JDBC driver to support the functionality required by that application. The J2EE Platform Specification requires J2EE Application Servers to make a Data Source implementation (that is, a connection pool for JDBC connections) available for this purpose. Tomcat offers the same support so that database-based applications developed on Tomcat using this service will run unchanged on any J2EE server.

To edit a Data Source,

  1. Expand the Resources element in the left pane.
  2. Select the Data Source to edit.
  3. Edit the values in the right pane.
  4. Select Save to save the changes for this session. Select Commit Changes to save the changes for when Tomcat is restarted.

To create a new Data Source for Tomcat,

  1. Select the Data Source node.
  2. Select Create New Data Source from the Available Actions list.
  3. Enter the preferred values for the new Data Source. See Table A-17 for details on the attributes.
  4. Select Save to save the changes for this session. Select Commit Changes to save the changes for when Tomcat is restarted.

Data Source Attributes


Note: In order to use a Data Source, you must have a JDBC driver installed and configured.


The attributes outlined in Table A-17 may be viewed, set, or modified for a Data Source.

Table A-17 Data Source Attributes 
Attribute
Description
JNDI Name
The JNDI name under which you will look up preconfigured data sources. By convention, all such names should resolve to the jdbc subcontext (relative to the standard java:comp/env naming context that is the root of all provided resource factories.) For example, this entry might look like jdbc/EmployeeDB.
Data Source URL
The connection URL to be passed to the JDBC driver. One example is jdbc:HypersonicSQL:database.
JDBC Driver Class
The fully-qualified Java class name of the JDBC driver to be used. One example is org.hsql.jdbcDriver.
User Name
The database user name to be passed to the JDBC driver.
Password
The database password to be passed to the JDBC driver.
Max. Active Connections
The maximum number of active instances that can be allocated from this pool at the same time. Default value is 4.
Max. Idle Connections
The maximum number of connections that can sit idle in this pool at the same time. Default value is 2.
Max. Wait for Connections
The maximum number of milliseconds that the pool will wait (when there are no available connections) for a connection to be returned before throwing an exception. Default value is 5000.
Validation Query
A SQL query that can be used by the pool to validate connections before they are returned to the application. If specified, this query MUST be an SQL SELECT statement that returns at least one row.

Configuring Environment Entries

Use this element to configure or delete named values that will be made visible to Web applications as environment entry resources. An example of an environment entry that might be useful is the absolute path to the Java WSDP installation, which is already defined as an Environment Entry.

To edit an Environment Entry,

  1. Expand the Resources element in the left pane.
  2. Select Environment Entries in the left pane.
  3. Select the Environment Entry to edit in the right pane. By default, an environment entry for the absolute path to the Java WSDP installation displays.
  4. Edit the values in the right pane.
  5. Select Save to save the changes for this session. Select Commit Changes to save the changes for when Tomcat is restarted.

To create a new Environment Entry for Tomcat,

  1. Select the Environment Entries element in the left pane.
  2. Select Create New Env Entry from the Available Actions list.
  3. Set the Environment Entries attributes. See Environment Entries Attributes for more information on the options.
  4. Select Save to save the changes for this session. Select Commit Changes to save the changes for when Tomcat is restarted.

Environment Entries Attributes

Table A-18 Environment Entries Attributes 
Attribute
Description
Name
The name of the environment entry to be created, relative to the java:comp/env context. For example, jwsdp.home.
Type
The fully qualified Java class name expected by the Web application for this environment entry: 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 convertible to the Java type defined by the type attribute. For example, <path_to_home_directory>/jwsdp-1_0.
Override Application Level Entries
Whether or not you want an Environment Entry for the same environment entry name, found in the Web application's deployment descriptor, to override the value specified here. Unselect this option if you do not want an Environment Entry for the same environment entry name, found in the Web application's deployment descriptor, to override the value specified here. By default, overrides are allowed.
Description
An optional, human-readable description of this environment entry.

The valid attributes for an Environment element are outlined in Table A-18.

Configuring User Databases

Use this Resource to configure and edit a database of users for this server. The default database, <JWSDP_HOME>/conf/tomcat-users.xml, is already defined.

To edit a User Database,

  1. Expand the Resources element in the left pane.
  2. Select User Databases in the left pane.
  3. Select the User Database to edit in the right pane. By default, a user database for Tomcat displays.
  4. Edit the values in the right pane.
  5. Select Save to save the changes for this session. Select Commit Changes to save the changes for when Tomcat is restarted.

To create a new User Database for Tomcat,

  1. Select the User Databases element in the left pane.
  2. Select Create New User Database from the Available Actions list.
  3. Set the User Database attributes. See User Database Attributes for more information on the options.
  4. Select Save to save the changes for this session. Select Commit Changes to save the changes for when Tomcat is restarted.

User Database Attributes

Configure a User Database with the attributes outlined in Table A-19.

Table A-19 User Database Attributes 
Attribute
Description
Name
The name of the user database to be created, for example, UserDatabase.
Location
The location where the user database should be created, for example, conf/tomcat-users.xml.
Factory
The type of factory to use for this database, org.apache.catalina.users.MemoryUserDatabaseFactory.
Description
A human-readable description of what type of data the database holds, for example, Users and Groups Database.

Divider
Download
FAQ
History
PrevHomeNext API
Search
Feedback
Divider

All of the material in The Java(TM) Web Services Tutorial is copyright-protected and may not be published in other works without express written permission from Sun Microsystems.