| JNDI External Resource Sample Application |
JNDI External Resource Sample Application
This document describes how to use the Java Naming and Directory Interface (JNDI) external resource sample application with Sun Java System Web Server.This document contains the following sections:
- Overview
- Compiling and Assembling the Application
- Deploying the Sample Application
- Running the Sample Application
- Undeploying the Sample Application
Overview
The JNDI external resource sample demonstrates the use of the external resource.
Compiling and Assembling the Application
This section contains instructions for compiling and assembling the sample application.Note - Make sure that the necessary parameters for running the samples are specified in install_root/samples/java/webapps/common.properties.
- Go to the install_root/samples/java/webapps/jndi/external/src directory.
- Ensure that the necessary parameters for creating the external resource are specified in the build.xml file, as follows:
<!-- ======================================================= -->
<!-- external resource properties -->
<!-- ======================================================= -->
<property name="resource.type" value="external-jndi-resource"/>
<property name="resource.name" value="externalresource/MyExternalConnectionFactory"/>
<property name="resource.enabled" value="true"/>
<property name="external.resource.jndilookupname" value="index.html"/>
<property name="external.resource.restype" value="org.apache.naming.resources.Resource"/>
<property name="external.resource.factoryclass" value="samples.jndi.externalResource.MyExternalConnectionFactory"/>
<property name="external.resource.properties" value="basedir=${install.root}/${instance.name}/docs"/>
<property name="class.path.suffix" value="${install.root}/samples/java/webapps/jndi/external/src/docroot/WEB-INF/lib/external_resource.jar"/>
Note - Make sure that index.html is available in the install_root/instance_name/docs directory. If you want to test a different file, change the values in the build.xml file. When you execute the ant targets, ${install.root} is replaced by the install_root path, and ${instance.name} is replaced by the instance_name. install.root and instance.name are defined in the install_root/samples/java/webapps/common.properties directory.
Note - Change to install_root/samples/java/webapps/jndi/external/src and execute the ant command. The default target default will be executed to build the WAR file and a jar file in the external sample directory install_root/samples/java/webapps/jndi/external/src/docroot/WEB-INF/lib/external_resource.jar.
- Run the ant command to create the external-jndi-resource element.
# ant create_external
install_root/samples/java/webapps/jndi/external/src/docroot/WEB-INF/lib/external_resource.jar is added to the class-path-suffix element.
To run this command successfully, Administration Server must be running, and necessary parameters such as config.name, vs.name,
passwordfile.path etc. in install_root/samples/java/webapps/common.properties file must be specified correctly. (See 1. above)
- Deploy the application.
After you have created the sample application from scratch, you can proceed to Deploying the Sample Application.
- (Optional.) Clean the web application project area.
- # ant clean
This removes the assemble and build directories for the sample application. The jar file is now ready for deployment.
Deploying the Sample Application
To deploy the sample application, complete the following steps:
If you want to verify registration of the application, proceed to Verifying Deployment. Otherwise, proceed to Running the Sample Application.
- Change to the source directory at install_root/plugins/java/samples/webapps/jndi/external/src.
- Run the ant tool using the deploy task.
To verify the registration and deployment of the application, complete the following steps:
Change to the source directory at install_root/samples/java/webapps/jndi/external/src.
Run the ant tool using the list_apps task.
# ant list_apps
The jndi-externalresource module is listed as one of the components.
Running the Sample Application
You can run the application through the following URL:
http://Sun_Java_System_Web_Server_hostname:port/jndi-externalresource/externalresource.jsp
The index.html file size is displayed.
Undeploying the Sample Application
After successfully deploying and running the application, you might decide to undeploy it and remove the files.To undeploy the application, complete the following steps:
Change to the source directory at install_root/samples/java/webapps/jndi/external/src.
Run the ant tool using the undeploy task.
- Run the ant tool using the delete_resource task.
# ant delete_resource
This removes the deployed resource.
Copyright © 2007 Sun Microsystems, Inc. All rights reserved.