Sun ONE logo    
JNDI External Resource Sample Application

External Resource Sample Application


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

This sample application document contains the following sections:


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.

  1. Go to the <install_root>/plugins/java/samples/webapps/jndi/external/src/ directory.

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

      <!-- ======================================================= -->
      <!--          external resource properties                     -->
      <!-- ======================================================= -->
       <property name="external.resource.jndiname"       value="externalresource/MyExternalConnectionFactory"/>
       <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.enabled"        value="true"/>
       <property name="external.resource.property"       value="basedir=${WS_INSTALLROOT}/docs"/>


    Note:
    (1) Make sure index.html is available under the <install_root>/docs directory. If you want to test a different file, change the values in the build.xml file. When you execute the ant targets, ${WS_INSTALLROOT} will be replaced by the <install_root> path. WS_INSTALLROOT is defined in the <install_root>/plugins/java/samples/webapps/common.properties directory.

    (2) Go to <install_root>/plugins/java/samples/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 under the external sample directory <install_root>/plugins/java/samples/webapps/jndi/external/src/docroot/WEB-INF/lib/external_resource.jar.
         
         Open the server.xml file of the web server instance.
         Add the following to the classpathsuffix:     <install_root>/plugins/java/samples/webapps/jndi/external/src/docroot/WEB-INF/lib/external_resource.jar.
         For example, check the following sample JAVA element (/ws61 is the <install_root>):
       Change it from this:
    <JAVA javahome="/ws61/bin/https/jdk" serverclasspath="/ws61/bin/https/jar/webserv-rt.jar: ${java.home}/lib/tools.jar:/ws61/bin/https/jar/webserv-ext.jar:/ws61/bin/https/jar/webserv-jstl.jar: /ws61/bin/https/jar/ktsearch.jar" classpathsuffix="" envclasspathignored="on" debug="false" debugoptions="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n" dynamicreloadinterval="2"> ........ ........ </JAVA> to this: <JAVA javahome="/ws61/bin/https/jdk" serverclasspath="/ws61/bin/https/jar/webserv-rt.jar: ${java.home}/lib/tools.jar:/ws61/bin/https/jar/webserv-ext.jar:/ws61/bin/https/jar/webserv-jstl.jar: /ws61/bin/https/jar/ktsearch.jar" classpathsuffix="/ws61/plugins/java/samples/webapps/jndi/external/src/docroot/WEB-INF/lib/external_resource.jar" envclasspathignored="on" debug="false" debugoptions="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n" dynamicreloadinterval="2"> ........ ........ </JAVA>
       Save that file and restart the server.
  3. Execute the following command:

     ant create_external.

    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/external/src
     
  2. Run ant using the deploy task:
    ant deploy
If you want to verify registration of the application, proceed to Verifying Deployment. Otherwise, proceed to Running the Sample Application.
 

Verifying Deployment

  • Go to the src directory of the sample:
    <install_root>/plugins/java/samples/webapps/jndi/external/src
  • Execute the following command:
    ant list_apps
    You will see the jndi-externalresource module displayed as one of the listed components.
     
  • Undeploying the Application

    1. Go to <install_root>/plugins/java/samples/webapps/jndi/external/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-externalresource/externalresource.jsp

    It will display the index.html file size.


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