Sun Java System logo     
BMP Enroller Sample Application



BMP Enroller Sample Application


This document describes how to utilize the BMP Enroller sample application in conjunction with Sun Java (tm) System Application Server 7.

This sample application document contains the following sections:



Overview

In this section, the BMP Enroller sample application is described.

The BMP Enroller sample demonstrates the use of mapping a many-to-many relationship between database tables to a pair of entity beans with bean-managed persistence. In a many-to-many relationship, each entity may be related to multiple occurrences of the other entity. In this example, the beans will represent the relationship between a college course to students: a college course may have many students and each student may take several courses. There are 3 tables that are accessed by the StudentBean, CourseBean and EnrollerBean classes: the enrollment, course, and student table.

The following instructions describe how to assemble, 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/enroller/javadocs/index.html.

In order to successfully deploy and run the BMP Enroller 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:

  1. Compile and Assemble Cart. For example:

    Execute asant under <s1as_install_dir>/samples/ejb/bmp/enroller/src/

    The default target core will be executed to rebuild the JAR and EAR files.

  2. Deploy the application.

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

  3. Clean the web application project area. For example:

    Execute asant clean to remove the sample application's assemble and build directories.

You are now ready to use this EAR file for deployment.



Deploying the Sample Application



You may select one of the following methods of deploying and registering the 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.

There are two command line utilities to deploy the application, Using asant script or Using asadmin command.


Using asant script

  1. Go to the src directory of the sample. For example:

    cd <s1as_install_dir>/samples/ejb/bmp/enroller/src

  2. Execute the following command:

    asant deploy


Using asadmin command

  1. Go to the root of the sample directory. For example:

    <s1as_install_dir>/samples/ejb/bmp/enroller/

  2. Execute asadmin to deploy the module to the local application server instance. For example, go to:

    asadmin deploy -u <user-name> -w <password> -H <hostname> -p <admin server port> --instance <instance name> bmp-enroller.ear

The deployment process involves the following operations:

  • 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 and embedded JAR file

    • Explodes the bits into repository

    • Registers the J2EE application bmp-enroller by updating server.xml.

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.


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:

    asadmin list-components -u <username> -w <password> -H <host> -p <admin-port> <server instance name>

    You will see the bmp-enroller app as one of the listed applications.

OR

  • 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 rRchive (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.

  1. Open the pre-existing sample EAR file.

  2. Start the admin server if not already started using one of the following two methods, depending on your Operations System:

    • Windows:

      Go to <s1as_install_dir>\domains\domain1\admin-server\

      Run startserv

    • UNIX

      Go to <s1as_install_dir>/domains/domain1/admin-server/

      Execute startserv

  3. Open the EAR file.

    • 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-enroller.ear) and Click OK.

    • You will be asked for the application name. Enter bmp-enroller and Click OK.

    If the deployment goes through fine, you will see the original pane with bmp-enroller 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:

  1. Go to the directory where the sample has been deployed.

  2. Run appclient using the following instructions.

    > cd <s1as_install_dir>/domains/domain1/server1/applications/j2ee-apps/bmp-enroller_1/

    > appclient -client bmp-enrollerClient.jar -name EnrollerClient -textauth

    You will see the following output:

    ...

    Denise Smith:

    220 Power J2EE Programming

    333 XML Made Easy

    777 An Introduction to Java Programming

    An Introduction to Java Programming:

    823 Denise Smith

    456 Joe Smith

    388 Elizabeth Willis



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/ejb/bmp/enroller/src directory.

  • If you encounter problems when running the application, review the log files at <s1as-install-dir>/domains/domain1/<server-instance>/logs/server.log to see what exactly went wrong.

  • In order to run the application again, you must run asant sql in the <install_dir>/samples/ejb/bmp/enroller/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