![]() |
JNDI URL Sample Application |
JNDI URL Sample Application
This document describes how to utilize the JNDI URL sample application in conjunction with Sun Java (tm) System Application Server 7.This sample application document contains the following sections:
Overview
Compiling and Assembling the Application
Deploying the Sample Application
Overview
The JNDI URL sample application demonstrates the usage of the JNDI resource to connect to a URL. The application uses an EJB for displaying the contents of a web page by connecting to its URL. The jndi-name element of EJB in sun-ejb-jar.xml specifies a target URL. The EJB is invoked by a client class.
Compiling and Assembling the Application
This section contains instructions to build and assemble the JNDI URL sample application using a Command Line Interface (CLI).To rebuild the entire application from scratch, follow these steps:
Add <install_dir>/bin to your path.
Go to <install_dir>/samples/jndi/url/src/.
The default target core will be executed to rebuild the JAR and EAR files.
- Execute the command asant
Clean the application project area (optional).
- After you have re-created the sample application from scratch, you may proceed to Deploying the Sample Application. Step 5 is optional.
- Execute the command asant clean to remove the sample application assemble and build directories.
- Now you are ready to use this ear file for deployment.
Deploying the Sample Application
In this section, you will learn how to deploy the JNDI URL sample application.Select one of the following approaches to deploying the application:
Command Line-based Deployment describes how to manually register the application in Sun Java (tm) System Application Server using a Command Line Interface (CLI). This is the fastest means of deploying the sample application.
Command Line-based DeploymentGUI-based Deployment describes how to use the Sun Java (tm) System Application Server Deployment Tool to import and deploy the sample application.
Since a complete EAR file is supplied, the fastest means of setting up the application is to use the command line utilities as described in this section.
The pre-built jndi-url.ear file is a Enterprise Archive file that contains the JAR file of the application. Within the JAR file resides the XML deployment descriptor files, application class files, and other content required by the application.
Deploying the pre-built jndi-url.ear file is simple. Deploy either using asant command or using asadmin command.
Go to the src directory of the sample. For example:
The deployment process involves the following operations:
Run asant using deploy task. For example:
- <install_dir>/samples/jndi/url/src
- %asant deploy
Authenticates against the local application server's administrative server
If you would like to verify the registration of the application, you may proceed to Verifying Deployment. Otherwise, proceed to Running the Sample Application.The EAR file is transferred to the administrative server
The administrative server begins the registration process:
Since a pre-built Enterprise Archive (EAR) file for the sample application is included with the application server, you may use the Sun Java (tm) System Application Server Administration Tool to quickly read in the .ear file and deploy it to the application server.
From your web browser, access the Sun Java (tm) System Application Server by executing the following:
If the deployment processes correctly, you will see the original panel displaying the JNDI URL application as deployed.
Open the EAR file
- <install_dir>/domains/domain1/admin-server/bin/startserv
Navigate to the browser based admin server page. For example:
Enter your username and password to access the admin server.
- http://<server-host>:<admin-port>/index.html
In the left pane, navigate the tree by clicking on the following:
In the right hand pane, click on Deploy button to deploy an application.
- App Server Instances>server1>Applications>Enterprise Apps
You will be prompted for the application name.
- Select the file (from disk) to be deployed (jndi-url.ear) and Click OK.
- Type jndi-url and Click OK.
Verifying Deployment
As an optional step, you can use the Sun Java (tm) System Application Server Administration Tool to verify that the application has been registered. Otherwise, proceed directly to Running the Sample Application.To verify the registration of the application, do the following:
Execute the command asadmin list-components to look at applications deployed with a server instance. For example:
asadmin list-components -u <username> -w <password> -H <host> -p <admin-port> <server instance name>.
Running the Sample Application
The URL connection factories do not require any resources to be created in server.xml. The application is run by running the client class, which invokes the Ejb.To run the JNDI URL sample application, do the following:
Go to the following directory: <install-dir>/domains/domain1/<server-instance>/applications/j2ee-apps/jndi-url_1/
- <install_dir>/bin/appclient -client jndi-urlClient.jar -name jndi-urlClient -textauth
- The contents of the index.html file that resides in <install_dir>/samples/ will be displayed.
Generating javadocs
To better understand sample application source code, you may refer to the related javadocs.To generate javadocs, run one of the following commands:
After javadocs are generated, you may access them at <install_dir>/samples/jndi/url/javadocs/index.html.
The URL specified under sun-ejb-jar.xm l assumes the http server port of Sun Java (tm) System application server installation to be 1024. If the port is other than 1024, you must modify sun-ejb.jar.xml before compiling and deploying the sample.
Please make sure that you run asant undeploy before redeploying this sample. This will ensure that all modules are undeployed and the resources are disabled.
Although the ear, context-root and servlet alias names in this sample are all "jndi-url", it is not necessary that it be so. The application will work as expected if the names of each of these attributes is unique. Rebuild the application after changing the context-root (in application.xml), the and ear names (in the build.xml). Redeploy and test the sample to confirm thees changes.
If you encounter problems when running the application, review the log files at <install-dir>/domains/domain1/<server-instance>/logs/server.log to learn what exactly went wrong.
Copyright © 2002 Sun Microsystems, Inc. All rights reserved.
Last Updated July 11, 2002