EJB Deployment   «Prev 

Deploy Test BankAccount Bean - Exercise

Course Project, Part 1A: Deploy and test the BankAccount bean

Objective: Deploy the BankAccount bean and test it with the provided BankCustomer client

Exercise scoring

This exercise is worth a total of 5 points. To receive full credit, you willl need to deploy the BankAccount bean and test it with the provided BankCustomer.

Background/overview

I have provided a very simple BankAccount bean. The home interface contains the following create() methods:
BankAccount create() 
BankAccount create(String accountName) 
The bean's methods are as follows:
double getBalance() 
void credit(double amount) 
void debit(double amount) throws NSFException
String getInfo() 
Your job is to deploy and test it. The BankCustomer program creates a BankAccount instance, then credits and debits the account displaying its progress as it goes.
Some words of explanation for the BankAccount bean are in order:
  1. This wraps up Module 5.
  2. BankAccount is a very simple class. It remembers the current balance and the name of the customer. The balance starts as 0.0.
  3. It is created with either no name or an account name. If no name is provided, the account name will be named anonymous.
  4. getBalance() returns the current balance.
  5. credit() adds the amount to the balance.
  6. debit() subtracts the amount from the balance. If the balance would become negative by debiting the amount, it throws a NSFException (Non Sufficient Funds) and leaves the balance as it was.
  7. getInfo() returns a String that contains the account name and the balance.

Download files

This will download the following files:
  1. BankAccount.class
  2. BankAccountHome.class
  3. BankCustomer.skel
  4. runClient.bat
  5. BankAccountBean.class
  6. NSFException.class
  7. BankCustomer.class
  8. compileClient.bat Put these in a directory named bank. You will be testing the BankAccount bean using the BankCustomer.class.

    Instructions

    Deploy the BankAccount bean on the J2EE platform using the same procedure as you used in the previous exercises. You will have to edit the script files to match your local environment. Use the application name BankApp. Use the JNDI name MyBankAccount as this is the name used in the provided BankCustomer.class file. Remember the J2EE server must have been started before completing the steps below. The steps in this process are:
    1. Open a window and make the bank directory, where you downloaded the files for this exercise, current.
    2. Start the deploytool
    3. Create a new application, by choosing New Application... from the File menu. Name it "BankApp".
    4. By selecting New Enterprise Bean... from the File menu, add the BankAccount bean to the application. When adding contents to the JAR file, select the files BankAccount.class, BankAccountBean.class, BankAccountHome.class, and NSFException.class.
    5. Deploy the application by selecting Deploy Application... from the Tools menu.
    6. When prompted to do so, specify the JNDI name for the bean as "MyBankAccount".
    7. When the deployment is complete, click OK.
    8. In a separate window, edit (if required), and then execute the runClient script file, which should produce the results shown on the exercise results page.

    Hints

    If you have any problems with any part of this exercise, please contact a tutor. If the BankCustomer client does not access the BankAccount bean when you execute it, make sure the BankAccount bean was successfully deployed on the J2EE platform by examining the window of the J2EE program. If nothing is shown there, make sure you started the program with the -verbose flag.

    Submitting your exercise

    When you have completed your exercise, paste the output of the BankCustomer client in the text box below and click the Submit button to submit your exercise.