![]() |
BMP Order Sample Application |
BMP Order Sample Application
This document describes how to utilize the BMP Order 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
In this section, the BMP Order sample application is described.The BMP Order sample demonstrates the use of mapping a one-to-many relationship between database tables to a helper class and an entity bean with bean-managed persistence. Not every database table needs to be mapped to an entity bean. If the table does not represent a business entity or if the information is stored in another entity, then the table should be represented by a helper class.
In this example, the order application simulates an online shopping application where each order submitted can have multiple line items. The orders table has a one to many relationship with the LineItems table, where the primary key (orderid) of the orders table serves as the foreign key to the lineitems table. Note that the primary key of the lineitems table is the itemno. Not only does a line item belong to an order, it also does not exist without the order. Therefore, the lineitems table should be represented with a helper class and not with an entity bean. Using a helper class in this case is not required, but doing so might improve performance because a helper class uses fewer system resources than an entity bean.
The following instructions describe how to assemble and deploy on the Application Server, and how to access the EJB. Although the client application and the EJB offer minimal functionality, this sample should provide you with a basic understanding of EJBs in the Sun Java (tm) System Application Server.
You may refer to Running the Sample Application to do so.
To better understand sample application source code, you can generate javadocs using asant javadocs and access them at <install_root>/samples/ejb/bmp/order/javadocs/index.html.
In order to successfully deploy and run the BMP Order sample application, Database resources (PointBase) needs to be setup with the Application Server.
If you want to run this sample on Oracle Database, please refer to (How to run sample applications with Oracle ) .
Compiling and Assembling the Application
To rebuild the entire application from scratch, follow these steps:
Compile and Assemble Cart. For example:
You are now ready to use this EAR file for deployment.
Deploy the application.
- Execute asant under <sjsas_install_dir>/samples/ejb/bmp/order/src/
- The default target core will be executed to rebuild the JAR and EAR files.
Clean the web application project area. For example:
- Once you have re-created the sample application from scratch, you may proceed to Deploying the Sample Application.
- Execute asant clean to remove the sample application's assemble and build directories.
Deploying the Sample Application
You may select one of the following methods of deploying and registering the application:
Command Line Interface (CLI)-based Deployment describes how to manually register the sample application using a Command Line Interface (CLI). This is the fastest means of deploying the application to the application server.
Web Interface (GUI)-based Deployment describes how to use the Sun Java (tm) System Deployment Tool to import and deploy the sample application.
Command Line Interface (CLI)-based Deployment
Since the sample application is supplied with a complete EAR file, the fastest means of setting up the application is to use the command line utilities as described in this section. If you would like to experience either deploying through a Web based tool, then follow instructions in Web Interface (GUI)-based Deployment.The pre-built bmp-order.ear file is a Enterprise Archive file that contains the Java Archive (JAR) files of the application. Since this application consists of EJB and client, it will have two jar files (one for each). Individual JAR files have the XML deployment descriptor files, application class files and other content as required by the application.
There are two command line utilities to deploy the application, Using asant script or Using asadmin command.
Go to the src directory of the sample. For example:
Execute the following command:
- <sjsas_install_dir>/samples/ejb/bmp/order/src
- asant deploy
Go to the root of the sample directory. For example:
The deployment process involves the following operations:
Execute asadmin to deploy the module to the local application server instance. For example, go to:
- <sjsas_install_dir>/samples/ejb/bmp/order/
- asadmin deploy -u <user-name> -w <password> -H <hostname> -p <admin server port> --instance <instance name> bmp-order.ear
Authenticates against the local application server's administrative server.
If you would like to verify the registration of the application, proceed to Verifying Registration. Otherwise, you are now ready to exercise the application by Running the Sample Application.The EAR file is transferred to the administrative server.
The administrative server begins the registration process:
Verifying Registration
As an optional step, you can use the Sun Java (tm) System 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, do one of the following:
Execute asadmin to look at applications deployed with a server instance. For example:
OR
- asadmin list-components -u <username> -w <password> -H <host> -p <admin-port> <server instance name>
- You will see the bmp-order app as one of the listed applications.
Navigate the Admin tool GUI to
- App Server Instances>server1>Applications>Enterprise Apps.
- Click on Enterprise Apps on the left frame menu to diplay list of applications deployed on server.
Web Interface (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 Sun Java (tm) System Application Server Administration 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 not already started using one of the following two methods, depending on your Operations System:
Windows:
Open the EAR file.
UNIX
- Go to <sjsas_install_dir>\domains\domain1\admin-server\
- Run startserv
- Go to <sjsas_install_dir>/domains/domain1/admin-server/
- Execute startserv
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 on App Server Instances>server1>Applications>Enterprise Apps.
In the right hand pane, click on Deploy to deploy an application. Choose the file (from disk) to be deployed (bmp-order.ear) and Click OK.
You will be asked for the application name. Enter bmp-order and Click OK.
- If the deployment goes through fine, you will see the original pane with bmp-order application as deployed.
Running the Sample Application
This describes how to start and navigate through the application.Running the sample is a two step process:
Go to the directory where the sample has been deployed.
Run appclient using the following instructions.
- > cd <sjsas_install_dir>/domains/domain1/server1/applications/j2ee-apps/bmp-order_1/
- > appclient -client bmp-orderClient.jar -name OrderClient -textauth
- You will see the following output:
- ...
- 123 1 p23 12.0
- 123 2 p67 89.0
- 123 3 p11 41.0
- 123
- 456
Note In order to run the application again, you must run asant sql in the <install_dir>/samples/ejb/bmp/order/src directory in order to restore the database to its original state.
Make certain that you run asant undeploy before redeploying this sample to make sure that all modules are undeployed and the resources are disabled.
You may also restore the orginal state of the database by executing asant sql in the <install_dir>/samples/ejb/bmp/order/src directory.
If you encounter problems when running the application, review the log files at <sjsas-install-dir>/domains/domain1/<server-instance>/logs/server.log to see what exactly went wrong.
Copyright © 2002 Sun Microsystems, Inc. All rights reserved.
Last Updated July 26, 2002