CMP Customer Sample Application

  Samples Index




CMP Customer Application


This document describes how to utilize the CMP Customer sample application in conjunction with the Application Server.

This sample application document contains the following sections:



Overview

The following instructions describe how to assemble and deploy the same EJB to the Application Server and how to access the EJB from a Servlet client using HTTP. Although the client application and EJB offer minimal functionality, this sample should provide you with a basic understanding CMP support in the Application Server.



Compiling and Assembling the Application



To recompile, assemble, and deploy the application, see the Sample Application Build Facility document for details on using a build facility to quickly perform these tasks.

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

  1. Compile and assemble the J2EE application.

    Execute the asant command under <install_dir>/samples/ejb/cmp/apps/cmpcustomer

    The default target core is executed to rebuild the .jar and .ear files.

  2. Deploy the application.

    Once you have re-created the sample application from scratch proceed to deploying the Application.

  3. Clean the application project area.

    Execute the asant clean command to clean the application area.

  4. Undeploy the application.

    Execute the asant undeploy command to undeploy the application.



Deploying the Application

A pre-built cmpcustomer.ear file is supplied with the application server installation. The pre-built cmpcustomer.ear file is an Enterprise Archive (.ear) file that contains, the EJB .jar file, the web applicatation .war file of the application. Within each file resides 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 experience compiling and assembling the application from scratch, follow the instructions in 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:

UNIX

Windows

Select one of the following approaches to deploy the application:


Command Line-based Deployment

Command Line Interface is the fastest means of deploying the application.If you want to deploy through a GUI tool, follow the instructions for GUI Based Deployment. CLI deployment of the application can be done using either the asant script or using the asadmin command.

Deployment process includes deploying the application EAR, configuring database and registering required resources to application server. Installation comes with already configured pointbase database. If you choose to use prepopulated pointbase database, you do not need to configure database.


Deploy the Application Using asant

Please start your database server, if not started.

If you choose to use the PointBase database, execute the following steps:




Note You must run asant undeploy before redeploying this sample. This will ensure that all modules are undeployed and the resources are disabled.




Deploy the Application File Using the asadmin Command

Now you need to register the resources to the application server. Proceed to Configuring Resources.

The deployment process involves the following operations:

If you want to verify the registration of the application, proceed to Verifying Deployment.



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 (cmpcustomer.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.


Now you need to register the resources with the application server. Proceed to Configuring Resources.

Configuring Resources


This section describes how to create resources required for running cmpcustomer application. You do not need to register them separately when you deploy the application using the asant deploy command. However, the resources can be registered as follows:



Running the Sample Application

The application be executed, using web client and using appclient container.


Execute Servlet Client

To run the web application, go to the following URL:

http://<web server hostname>:<port>/customer

If your deployment process was successful,  you should be able to access application via URL:  

http://localhost:8080/customer






Verifying Deployment


 
As an optional step, you can use the Application Server Administration GUI 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, execute the asadmin command to look at applications deployed with a server instance:

asadmin list-components  --user <user> --password <password> --type application 



Generating Javadocs


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

To generate javadocs run the following command:

asant javadocs

or

asant all

After javadocs are generated, you can access them at

<install_dir>/samples/ejb/cmp/apps/cmpcustomer/javadocs/index.html



Troubleshooting



Make certain that you run the asant undeploy command before redeploying this sample to make sure that all modules are undeployed and the resources are disabled.

If you encounter problems when running the application, review the log files at <install-dir>/domains/<domain_name>/logs/server.log to learn what went wrong.

 



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

Last Updated February 12, 2004