Sun ONE logo    
JNDI Custom Resource Sample Application

Custom Resource Sample Application


This document describes how to use the JNDI custom resource sample application in conjunction with Sun ONE Web Server.

This sample application document contains the following sections:



Overview
 
The JNDI custom resource sample demonstrates the use of the custom resource.  


Compiling and Assembling the Application



This section contains instructions for compiling and assembling the sample application.
  1. Go to <install_root>/plugins/java/samples/webapps/jndi/custom/src and execute the ant command.

    The default target 'default' will be executed to build the WAR file.

  2. Make sure the necessary parameters for creating  the custom resource are specified in the build.xml file, as follows:

      <!-- ======================================================= -->
      <!--          custom resource properties                     -->
      <!-- ======================================================= -->
       <property name="custom.resource.jndiname"     value="customresource/MyCustomConnectionFactory"/>
       <property name="custom.resource.resourcetype" value="samples.jndi.customResource.MyBean"/>
       <property name="custom.resource.factoryclass" value="samples.jndi.customResource.MyCustomConnectionFactory"/>
       <property name="custom.resource.enabled"      value="true"/>
       <property name="custom.resource.property"     value="info=Hello"/>

  3. Execute the following command:

         ant create_custom

    Then restart the web server instance.

  4. Deploy the application.

    After you have created the sample application from scratch, you can proceed to Deploying the Sample Application. Step 5 is optional.
     
  5. To clean the web application project area (optional), execute the following command:

    ant clean

  Deploying the Sample Application

To deploy the sample application, perform the following steps:
  1. Go to the src directory of the sample:

    <install_root>/plugins/java/samples/webapps/jndi/custom/src
     
  2. Run ant using the deploy task:

    ant deploy
If you want to verify the registration of the application, proceed to Verifying Deployment. Otherwise, proceed to Running the Sample Application.
 

Verifying Deployment

ant list_apps

You will see the jndi-customresource module displayed as one of the listed components.
 

Undeploying the Application

  1. Go to <install_root>/plugins/java/samples/webapps/jndi/custom/src

  2. Execute the following command:

    ant undeploy


Running the Sample Application



You can run the application through the following URL:

http://<Web_Server_hostname>:<port>/jndi-customresource/customresource.jsp

It will display the word "Hello."


Copyright © 2003Sun Microsystems, Inc. All rights reserved.