GuessNumber Application |
GuessNumber Application
This document describes how to utilize the GuessNumber JavaServer Faces sample application in conjunction with the Application Server.This sample application document contains the following sections:
- Overview
- Compiling and Assembling the Application
- Deploying the Sample Application
Overview
The following instructions describe how to assemble, deploy to the Application Server, and how to access the GuessNumber sample application.
Compiling and Assembling the Application
This Command Line Based Compilation and Assembly procedure describes how to assemble and compile the sample using a Command Line Interface (CLI).
Command Line Based Compilation and Assembly
To rebuild the entire application from scratch:
- Compile and Assemble.
- Execute the asant command under <install_dir>/samples/jsf/apps/guessNumber/
- [please add <install_dir>/bin to your path]
- The default target core is executed to rebuild the .war file.
- Deploy the application.
- When you have re-created the sample application from scratch, proceed to Deploying the application.
- Clean the web application project area.
- Execute the asant clean command to remove the sample application's assemble and build directories.
- Now you are ready to use this .war file for deployment.
Deploying the Sample Application
Select one of the following approaches to deploy the application:
- Command Line Based Deployment describes how to manually register the application in a Application Server using a Command Line Interface (CLI). This is the fastest means of deploying the application.
- GUI Based Deployment describes how to use the Admin GUI to import and deploy the sample application.
Command Line Based Deployment
Since a complete .war file is supplied, the fastest means of setting up the application is to use the command line utilities as described in this section.If you want to deploy through a GUI tool, follow the instructions for GUI Based Deployment.
The pre-built jsf-guessNumber.war file is a Web Archive (WAR) file that contains the files of the application.
Since this application consists of EJB and client, it has two JARs - one for each. Individual JAR files have the XML deployment descriptor files, application class files, and other content as required by the application.
Deploy using either the asant script or the asadmin command.
- Go to the guessNumber directory of the sample:
- <install_dir>/samples/jsf/apps/guessNumber
- Execute the asant deploy command.
The deployment process involves the following operations:
- Go to the root of the sample directory:
- <install_dir>/samples/jsf/apps/guessNumber/
- Execute the asadmin command to deploy the application to the local application server instance:
- asadmin deploy --user <user-name> --password <password> --host <hostname> --port <admin server port> jsf-guessNumber.war
- It authenticates against the local application server's administrative server.
- The .war file is transferred to the administrative server.
- The administrative server begins the registration process:
- Parses the .war file.
- Explodes the bits into the repository.
- Registers the J2EE web application jsf-guessNumber by updating the domain.xml file.
- If you want to verify the registration of the application, proceed to the Verifying Deployment section.
- Otherwise, you are ready to exercise the application by Running the Sample Application.
GUI Based Deployment
Since a pre-built Web Archive (.war) file for the sample application is included with the application server, you can use the Admin GUI to quickly read in the .war file and deploy it to the application server.
- Start the admin server if it is not already started. Here are the commands for each platform:
- Unix - Execute the <install_dir>/bin/asadmin start-domain domain1 command.
- Windows - Click "Start->Programs->Sun Microsystems->J2EE 1.4 SDK->Start Default Server" command.
- Open the .war file.
- Start Admin GUI, by entering URL http://localhost:<admin.port>/asadmin in browser. See replacing "localhost" and <admin.port> note here to determine correct values to use for your environment
- You are prompted to supply the user name and password of the application server. Enter correct values for your installed application server for "User Name:" and "Password:" input fields, then click on the "Login" button.
- In the left-hand frame, click Applications-->Web Applications icon in the tree.
- In the right-hand frame, click on the "Deploy..." button.
- Choose the file to be deployed by clicking on the "Browse..." button, and navigate to select component to deploy (jsf-guessNumber.war).
- In the browse dialog, click on the "OK" button.
- In the right-hand frame, click on the "Next" button.
- In the right-hand frame, click on the "OK" button. (Optionally fill in remaining values for application to be deployed)
- In the left hand pane, you will see the newly deployed module's icon in the tree. In the right hand pane you will also see the component listed as deployed.
Verifying Deployment
As an optional step, you can use the 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, follow these steps:
- Execute the command asadmin list-components to look at applications deployed with a server instance. For example:
- asadmin list-components --user <user-name> --password <password>
- You will see jsf-guessNumber listed.
- Alternately, you may navigate the Admin tool GUI to the following:
- Applications-->Web Applications.
- On the left frame, Click on Web Applications to display list of web applications deployed on server.
- You will see jsf-guessNumber listed.
Running the Sample Application
Open a browser and enter the following URL (replacing localhost and port 8080 with appropriate values specific to your environment):
- http://localhost:8080/jsf-guessNumber
Generating Javadocs
To understand sample application source code better, you can refer to the related javadocs. To generate javadocs, run the command
After javadocs are generated, you can access them at
- asant javadocs
- or
- asant all
<install_dir>/samples/jsf/apps/guessNumber/javadocs/index.html
Troubleshooting
If you encounter problems when running the application, review the log files at <install-dir>/domains/<domain_name>/logs/server.log to see what went wrong.Make certain that you run asant undeploy before redeploying this sample to make sure that all modules are undeployed.
Copyright © 2004 Sun Microsystems, Inc. All rights reserved.
Last
Updated March 6, 2004