![]() |
Bean-Managed Transaction Teller Sample Application |
Bean-Managed Transaction Teller Sample Application
This document describes how to utilize the Bean-Managed Transaction Teller 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 Bean-Managed Transaction Teller sample application is described.The Bean-Managed Transaction Teller application uses bean managed-transactions with the javax.transaction.UserTransaction interface and demonstrates JTA transactions. JTA (Java Transaction API) allows you to demarcate transactions in a manner that is independent of the transaction manager implementation. The J2EE SDK implements the transaction manager with the Java Transaction Service (JTS). The code doesn't call the JTS methods directly but invokes the JTA methods with then calls the lower-level JTS routines.
A JTA transaction is controlled by the J2EE transaction manage and may be used to span updates to multiple databases from different vendors. A particular DBMS's transaction manager may not work with heterogeneous databases. However, the J2EE transaction manager does have one limitation, – it does not support nested transactions.
To better understand sample application source code, you can generate javadocs using asant javadocs and access them at <install_dir>/samples/transactions/ejb/bmt/teller/javadocs/index.html.
In order to successfully deploy and run the transactions-teller 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 compile and assemble the application, follow these steps:
Go to the src directory of the sample. For example:
Execute asant all under
- cd <install_dir>/samples/transactions/ejb/bmt/teller/src
Clean the web application project area. For example:
- The default target core will be executed to rebuild the JAR file.
- Execute asant clean to remove the sample application's assemble and build directories. This is required when you want to rebuild the application.
Deploying the Sample Application
The deployment process includes deploying the application EAR, configuring the database and registering required resources to Sun Java (tm) System Application Server. Installation comes with already configured PointBase database. If you choose to use prepopulated PointBase database, you do not need to configure the database.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. Alternatively, you can also assemble the application from scratch and deploy it using the Deployment Tool.
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.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:
- cd <install_dir>/samples/transactions/ejb/bmt/teller/src
- asant deploy
Go to the bin of the sample directory. For example:
Now you're ready to exercise the application. Follow instructions provided in Running the Sample Application.
Execute asadmin to deploy the module to the local application server instance. For example, go to:
- cd <install_dir>/bin/
Execute the following:
- sjsas_install_dir/samples/transactions/ejb/bmt/teller
Commit the changes. For example:
- asadmin deploy -u <user-name> -w <password> -H <hostname> -p <admin server port> --instance <instance name> transactions-teller.ear
- asadmin reconfig -H <host> -p <Admin Port> -u <user> -w <password> <instancename>
The transactions-teller.ear file is an Enterprise Archive (EAR) file that contains the Java Archive (JAR) file for the application containing the EJBs.
The deployment process involves the following operations:
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:
You will see the transactions-teller app as one of the listed applications.
- asadmin list-components -u <username> -w <password> -H <host> -p <admin-port> <server instance name>
Web Interface (GUI)-based Deployment
Login to web-based administration tool from browser.
Click on the Deploy icon.
- Application Server Instances --> <server instance> -- Applications --> Enterprise Applications
Use Browse button to locate the transactions-teller.ear file and then click OK button.
Type in product in "App Name" and then click OK.
Verify that the application is deployed by clicking on the product link.
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/transactions-teller_1/
- > appclient -client transactions-tellerClient.jar -name TellerClient -textauth
- You will see the following output:
- ...
- checking: 440.0
- checking: 380.0
Troubleshooting
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/transactions/ejb/bmt/teller/src directory.
When using the admin UI to restart the Sun Java (tm) System application server, it may be necessary to click on 'Apply Changes' then on 'RestartServer'.
In order to run the application again, you must run asant sql in the <install_dir>/samples/transactions/ejb/bmt/teller/src directory in order to restore the database to its original state.
Copyright © 2002 Sun Microsystems, Inc. All rights reserved.
Last Updated July 26, 2002