Download
FAQ History |
![]() ![]() ![]() |
API
Search Feedback |
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
<
JWSDP_HOME
>/docs/tomcat/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,
To create a new Data Source for Tomcat,
- Create a
Context
inserver.xml
and add aResourceLink
within the context. Theglobal
field of the Resource Link should be the name of the Global Resource you wish to add usingadmintool
. The name field of theResourceLink
should be the name you use as a Resource Reference inweb.xml
. The following example from aserver.xml
for Tomcat shows a simple Resource Reference and Context.
<Context
className="org.apache.catalina.core.StandardContext"
cachingAllowed="true"charsetMapperClass="org.apache.
catalina.util.CharsetMapper" cookies="true"
crossContext="false" debug="0" displayName="gs"
docBase="/home/your_name/work/Standard
Engine\localhost\manager\gs.war"
mapperClass="org.apache.catalina.core.
StandardContextMapper" path="/gs"
privileged="false"reloadable="false" useNaming="true"
wrapperClass="org.apache.catalina.core.StandardWrapper">
<ResourceLink global="jdbc/ActivityDB" name="ActivityDB"/>
</Context>
- Add the resource reference to the deployment descriptor for the application,
web.xml
. The following code shows an example of a resource reference in bold:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC
'-//Sun Microsystems, Inc.//DTD Web Application 2.3//
EN' 'http://java.sun.com/dtd/web-app_2_3.dtd'>
<web-app>
<display-name>gs</display-name>
<servlet>
<servlet-name>index</servlet-name>
<display-name>index</display-name>
<jsp-file>/index.jsp</jsp-file>
</servlet>
<resource-ref>
<res-ref-name>ActivityDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref></web-app>
The Resource created here is linked to the context via the Resource Link element.
- In
admintool
, select the Data Source element in the left pane.- Select Create New Data Source from the Available Actions list.
- Set the Data Source attributes. See Data Source Attributes for more information on the options. The JNDI Name you specify in
admintool
should match the Resource Reference name from theweb.xml
file and the Resource Link name fromserver.xml
. Add the Driver Name, URL, User Name, and Password.- Select Save to save the changes for this session. Select Commit Changes to save the changes for when Tomcat is restarted.
If you select Commit Changes, the
<
JWSDP_HOME
>/conf/server.xml
file will be updated with an entry forResourceParams
within theGlobalNamingResources
element, which might look like this:<GlobalNamingResources>
<Environment description="Absolute Path name of the JWSDP" Installation" name="jwsdp.home" override="true" type="java.lang.String" value="/home/your_name/jwsdp-1.2"/> <Resource auth="Container" description="Users and Groups Database" name="UserDatabase" scope="Shareable" type="org.apache.catalina.UserDatabase"/> <Resource name="jdbc/ActivityDB" scope="Shareable" type="javax.sql.DataSource"/> <ResourceParams name="UserDatabase"> <parameter> <name>factory</name> <value>org.apache.catalina.users. MemoryUserDatabaseFactory</value> </parameter> <parameter> <name>pathname</name> <value>conf/tomcat-users.xml</value> </parameter> </ResourceParams> <ResourceParams name="jdbc/ActivityDB"> <parameter> <name>validationQuery</name> <value></value> </parameter> <parameter> <name>user</name> <value>your_user_name</value> </parameter> <parameter> <name>maxWait</name> <value>5000</value> </parameter> <parameter> <name>maxActive</name> <value>4</value> </parameter> <parameter> <name>password</name> <value>your_password</value> </parameter> <parameter> <name>url</name> <value>jdbc:pointbase:server://localhost/ActivityDB</val ue> </parameter> <parameter> <name>driverClassName</name> <value>com.pointbase.jdbc.jdbcUniversalDriver</value> </parameter> <parameter> <name>maxIdle</name> <value>2</value> </parameter> </ResourceParams> </GlobalNamingResources>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-18 may be viewed, set, or modified for a Data Source.
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,
- Expand the Resources element in the left pane.
- Select Environment Entries in the left pane.
- 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.
- Edit the values in the right pane.
- 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,
- Select the Environment Entries element in the left pane.
- Select Create New Env Entry from the Available Actions list.
- Set the Environment Entries attributes. See Environment Entries Attributes for more information on the options.
- Select Save to save the changes for this session. Select Commit Changes to save the changes for when Tomcat is restarted.
Environment Entries Attributes
The valid attributes for an Environment element are outlined in Table A-19.
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,
- Expand the Resources element in the left pane.
- Select User Databases in the left pane.
- Select the User Database to edit in the right pane. By default, a user database for Tomcat displays.
- Edit the values in the right pane.
- 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,
- Select the User Databases element in the left pane.
- Select Create New User Database from the Available Actions list.
- Set the User Database attributes. See User Database Attributes for more information on the options.
- 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-20.
Download
FAQ History |
![]() ![]() ![]() |
API
Search Feedback |
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.