SimpleBank EJB Subclassing Sample Application

  Samples Index



SimpleBank EJB Subclassing Sample Application


This document describes how to utilize the SimpleBank EJB Subclassing sample application in conjunction with Application Server.

This sample application document contains the following sections:



Overview

This sample demonstrates the subclassing beans as a way to simplify related bean classes. In this SimpleBank example, the parent bean contains methods that are unique or can be overridden by the methods in the child bean. In this example, notice that there are no properties defined for the parent bean in the sun-ejb-jar.xml only the children have the properties defined.

Setting up the environment

In order to successfully deploy and run the JDBC SIMPLE 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



This section contains instructions to build and assemble the SimpleBank EJB Subclassing sample application using a Command Line Interface (CLI). Please refer to the Sample Application Build Facility document for details on using a build facility.

To rebuild the entire application from scratch, follow these steps:


  1. Compile and Assemble the application.

    Execute the asant command under <install_dir>/samples/ejb/misc/apps/subclassing.

    The default target core is executed to rebuild the .ear file.

Other useful targets:

  1. Deploy the application.

    After you have re-created the sample application from scratch, proceed to Deploying the Sample Application.


  2. Clean the application project area.

    Execute the command asant clean to clean the application area.


  3. Undeploy the application.

    Execute the command asant undeploy to undeploy the application.


  4. Build Javadocs.

    Execute the command asant javadocs to create Javadocs.

    The Javadocs are created under <install_dir>/samples/ejb/misc/apps/subclassing/javadocs.



NOTE: You must start the Database.


Please ensure that the database is started, (see How to start Database) before proceeding with deploying and running the sample application.


Deploying the Sample Application

In this section, you will learn how to deploy the SimpleBank EJB Subclassing sample application.

A pre-built subclassing .ear file is supplied with the application server installation. The pre-built subclassing .ear file is the Enterprise Archive (.ear) file of the application, which contain the ejb jar and war files. Within the ejb jar and war files reside the .xml deployment descriptor files, application class files, and other content required by the application. You can use the pre-built .ear file to deploy the application. If you want to compile and assemble the application from scratch, follow the instructions under Compiling and Assembling the Application.

To deploy the application, the administrative server needs to be running.

To start the administrative server if it is not already started:

Select one of the following approaches to deploying the application:


Command Line-based Deployment

The deployment process includes deploying the application .war file to the Sun ONE application server. CLI deployment of the application can be performed using either the asant script or the asadmin command.

To deploy the application using the asant command:


  1. >cd <install_dir>/samples/ejb/misc/apps/subclassing


  2. Execute the asant deploy command.

To deploy the application file using the asadmin command:


  1. >cd <install_dir>/samples/ejb/misc/apps/subclassing


  2. Execute the following command:

    asadmin deploy --user <username> --password <password> --host <host> --port <admin-port> subclassing.ear.

The deployment process involves the following operations:

You are now 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 GUI to quickly read in the .ear file and deploy it to the application server.

  1. Start the admin server if it is not already started. Here are the commands for each platform:
    1. Unix - Execute the <install_dir>/bin/asadmin start-domain domain1 command.
    2. Windows - Click "Start->Programs->Sun Microsystems->J2EE 1.4 SDK->Start Default Server"  command.
  2. Open the .ear file.
    1. 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
    2. 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.
    3. In the left-hand frame, click Applications-->Enterprise Applications  icon in the tree.
    4. In the right-hand frame, click on the "Deploy..."  button.
    5. Choose the file to be deployed by clicking on the "Browse..."  button, and navigate to select component to deploy (subclassing.ear).
    6. In the browse dialog, click on the "OK"  button.
    7. In the right-hand frame, click on the "Next"  button.
    8. In the right-hand frame, click on the "OK"  button. (Optionally fill in remaining values for application to be deployed)
    9. 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.

You may now proceed to Running the Sample Application.



Running the Sample Application



Perform the following steps to run the sample application:


  1. Go to http://<hostname>:<port>/subclassing/index.html


  2. Enter 123456789 as Customer Social Security Number.

    Click Edit.


  3. Enter data filling in the amounts.

    Press Update customer to update the required fields


  4. Return to the main page.

    Enter the SSN of a newly created customer.

    Press create.

    Repeat step 3

  5. Edit the amounts.

    Press Update customer to update the required fields.




  6. Return to the main page.

    Enter the same SSN.

    Press delete to delete the customer records.

You may verify all the operations by opening a SQL connection in a new window and running queries against the customer2 table.


Generating javadocs

To better understand sample application source code, you may refer to the related javadocs.

To generate javadocs, run one of the following commands:

asant javadocs

or

asant all

After javadocs are generated, you may access them at <install_dir>/samples/ejb/misc/apps/subclassing/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 learn what exactly went wrong.

Before redeploying the application again, please delete the jdbc resources as follows:

    asant unsetup

Some Known Issues:

  • While running the sample, entering decimal amounts against Savings Account and Checking Account may result in 500 internal error.



Copyright © 2004 Sun Microsystems, Inc. All rights reserved.

Last Updated March 6, 2004