![]() |
SavingsAccount (bmp) Application |
SavingsAccount (bmp) Application
This document describes how to utilize the SavingsAccount (bmp) sample application in conjunction with the Sun ONE Application Server version 7.This sample application document contains the following sections:
Overview
Compiling and Assembling the Application
Deploying the Sample Application
Overview
This sample is based on the SavingsAccount sample included in Sun's J2EE Developer's Guide, version 1.2.1 and illustrates the functionality with Bean-Managed Persistence. The EJB that represents a savings account keeps its state in a table of relational database.The following instructions describe how to assemble, deploy on the Application Server, and how to access the EJB. Although the client application and EJB offer minimal functionality, this sample should provide you with a basic understanding of EJBs in the Sun One Application Server.
The EJB uses relational database and the following instructions describe how to register the JDBC resources.
Setting up the environment
In order to successfully deploy and run the bmp (savingsaccount) sample application, Database resources (PointBase) needs to be setup with the Application Server.If you want to run the bmp (savingsaccount) sample application with the Oracle database, please refer to (How to run samples with Oracle database server) for configuration steps.
Compiling and Assembling the Application
The 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.
Deploy the application.
- Execute the asant command under <install_dir>/samples/ejb/bmp/savingsaccount/src/.
- The default target core is executed to rebuild the .ear file.
Clean the web application project area.
- When you have re-created the sample application from scratch, proceed to deploying the application.
- Execute the asant clean command to remove the sample application's assemble and build directories.
- Now you are ready to use this .ear 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 Sun ONE 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 Sun ONE Deployment Tool to import and deploy the sample application.
Command Line Based Deployment
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.If you want to deploy through a GUI tool, follow the instructions for GUI Based Deployment.
The pre-built bmp-savingsaccount.ear file is an Enterprise Archive file that contains the Java Archive (JAR) 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 src directory of the sample:
Execute the asant deploy command.
- <install_dir>/samples/ejb/bmp/savingsaccount/src
Go to the root of the sample directory:
The deployment process involves the following operations:
Execute the asadmin command to deploy the application to the local application server instance:
- <install_dir>/samples/ejb/bmp/savingsaccount/
- asadmin deploy -u <user-name> -w <password> -H <hostname> -p <admin server port> --instance <instance name>bmp-savingsaccount.ear
It authenticates against the local application server's administrative server.
The .ear file is transferred to the administrative server.
The administrative server begins the registration process:
Parses the .ear file.
Explodes the bits into the repository.
Registers the J2EE application bmp-savingsaccount by updating the server.xml file.
- If you want to verify the registration of the application, proceed to Verifying Registration section.
- Otherwise, you are ready to exercise the application by Running the Sample Application.
GUI Based Deployment
Since a pre-built Enterprise Archive (.ear) file for the sample application is included with the application server, you can use the Admin Tool to quickly read in the .ear file and deploy it to the application server.
Open the pre-existing sample .ear file.
Start the admin server if it is not already started.
- UNIX
Open the .ear file.
- Windows
Navigate to the browser based admin server page [http://<server-host>:<admin-port>/index.html].
Enter your username and password to access the admin server.
Click App Server Instances>server1>Applications>Enterprise Apps.
In the right hand pane, click Deploy to deploy an application.
Choose the file (from disk) to be deployed (bmp-savingsaccount.ear).
Enter bmp-savingsaccount.
- You are prompted to supply the application name.
- If the deployment goes through properly, you see the original pane with bmp-savingsaccount application as deployed.
Verifying Registration
As an optional step, you can use the Sun ONE Application Server Administration Tool to verify that the application has been registered.If you do not want to verify that the application has been registered, proceed directly to Running the Sample Application.
To verify the registration of the application:
Execute the asadmin command to look at applications deployed with a server instance. You see the bmp-savingsaccount app as one of the listed applications.
Or navigate the Admin tool GUI to App Server Instances>server1>Applications>Enterprise Apps.
- asadmin list-components -u <username> -w <password> -H <host> -p <admin-port><server instance name>.
Click Enterprise Apps on the left frame menu to display a list of applications deployed on the server.
Running the Sample Application
Running the sample is a two step process.
Goto the directory where the sample has been deployed.
Run appclient using the following instructions.
- > cd < install_dir>/domains/domain1/server1/applications/j2ee-apps/bmp-savingsaccount_1
- > <install_dir>/bin/appclient -client bmp-savingsaccountClient.jar -name SimpleSavingsAccount -textauth
- You see the following output:
- ...
- balance = 68.25
- balance = 32.55
- 456: 44.77
- 730: 19.54
- 268: 100.07
- 836: 32.55
- 456: 44.77
- 4
- 7
Generating Javadocs
To understand sample application source code better, you can refer to the related javadocs. To generate javadocs run command
After javadocs are generated, you can access them at
- asant javadocs
- or
- asant all
<install_dir>/samples/ejb/bmp/savingsaccount/javadocs/index.html
Troubleshooting
If you encounter problems when running the application, review the log files at <install-dir>/domains/domain1/<server-instance>/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 and the resources are disabled.
Copyright © 2002 Sun Microsystems, Inc. All rights reserved.
Last Updated July 10, 2002