Java TM Custom JNDI Resource Factory Sample Application

  Samples Index



Custom JNDI Resource Factory Sample Application

This document describes how to create, install, configure, and use your own custom JNDI resource factory in the Sun Java System Application Server 8.1 2005Q1.

This document contains the following sections:



Overview

The Custom JNDI Resource Factory Sample Application demonstrates:

The JNDI custom factory described here can only create samples.jndi.custom.share.CustomBean beans.

Along with the custom JNDI factory, the sample application provides an application client component that illustrates how to use such a custom factory to obtain a CustomBean.


The Sample Application

The Custom JNDI Resource Factory sample application contains an application client that illustrates how to use the Custom JNDI Resource Factory.

The directory structure of the Sample Application is as follows (all paths are relative to <install_dir>/samples/jndi/apps/custom/):

custom-client/src/conf - contains the application client deployment descriptors required for deployment on the Application Server
custom-client/src/java/samples/jndi/custom/client - source code for the application client
custom-share/src/java/samples/jndi/custom/share - source code for the custom bean (CustomBean) object and the class implementing the Custom JNDI Resource Factory (MyJndiCustomFactory).


Compiling and Assembling the Application



This section contains instructions on how to build and assemble the application.

  1. Compile and assemble the application.
    1. Change directory to: <install_dir>/samples/jndi/apps/custom.
    2. Execute the command asant core. This command compiles all source files and assembles the following module:
      • jndi-custom.ear
      • Main application, containing an application client that illustrates how to use the Custom JNDI Resource Factory

  2. Deploy the application.
  3. After compiling the sources and assembling the EAR file, you may proceed to Deploying the Sample Application. Steps 3 and 4 are optional.
  4. Clean the application project area (optional).
  5. Execute the command asant clean to remove all the files generated in Step 1.
  6. Generate API documentation (optional).
  7. Execute the command asant javadocs under <install_dir>/samples/jndi/apps/custom. The API documentation will be located under <install_dir>/samples/jndi/apps/custom/javadocs.


Deploying the Sample Application

This section contains instructions on how to deploy the application on the Application Server.


Note

When you deploy this application, an application server custom resource associated with the Custom JNDI Resource Factory is also created. This custom resource will be looked up by the application components when they need to obtain objects created by the custom JNDI Factory (CustomBean objects). See the create-custom-resource target in the main build.xml file for more details about how this is done.


Execute the command asant deploy under <install_dir>/samples/jndi/apps/custom.

This command deploys the EAR file of the Custom JNDI Resource Factory sample application, jndi-custom.ear.


Verifying Deployment

As an optional step, you can use the asadmin command to verify that the application has been registered. Otherwise, proceed directly to Running the Sample Application.

To verify the registration of the application, execute the command asadmin list-components to look at applications deployed with a server instance. For example:

<install_dir>/bin/asadmin list-components --user <username> --password <password>

You will see the sample Custom JNDI Resource Factory listed as a J2EE application:

custom <j2ee-application>

Running the Sample Application

Execute the command asant run under <install_dir>/samples/jndi/apps/custom.

This command invokes the application client of the Custom JNDI Resource Factory sample application. The application client looks up the JNDI name of the resource associated with the custom JNDI resource factory (this resource was created during deployment). It then displays the values of the bean properties.


Troubleshooting

If you encounter problems when running the application, review the Application Server log file located at

<install_dir>/domains/<domain-name>/logs/server.log

to learn what exactly went wrong.


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

Last Updated August 2, 2004