Sun Java System Application Server 

Samples Index

The CMP Customer Sample Application

The CMP Customer application demonstrates using Container Managed Persistence (CMP) Enterprise JavaBeans (EJBs).

Setting Up the Environment

Before you deploy or run the application, you must ensure that a database resource has been configured for Application Server. The included asant deployment script automatically performs this step for you. But if you useanother deployment mechanism, you must perform it manually.

You can use any JDBC-compliant relational database server, but specific instructions are provided for the following:

Resrouce Configuration

The CMP Customer application requires configuration of JDBC resources. You do not need to register the resources separately when you deploy the application using the asant deploy command. But if you use another deployment mechanism, you must perform it manually as follows:

  1. Start the database server if you have not already done so.
  2. Configure the JDBC connection pool:
    asadmin create-jdbc-connection-pool --host admin-host --port admin-port
      --user user --password password
      --datasourceclassname datasource classname
      --property User=pbpublic:Password=pbpublic:url-property="JDBC URL"
      cmpcustomer-pool
      
    For Derby, use DatabaseName as the value for url-property. You must escape colons (:) and slashes (/) in JDBC URL. An example of JDBC URL is jdbc\:derby\:\/\/localhost\:1527\/DerbyDB;create=true.
  3. Configure the JDBC resource:
    asadmin create-jdbc-resource --host admin host --port admin port
    --user user --password password
    --connectionpoolid  "cmpcustomer-pool jdbc/cmpcustomer"
    
  4. Configure persistence manager factory resource
    asadmin create-persistence-resource
    --host admin-host --port admin-port
    --user user --password password
    --jdbcjndiname jdbc/cmpcustomer
    --factoryclass com.sun.jdo.spi.persistence.support.sqlstore.impl.PersistenceManagerFactoryImpl
    jdo/cmpcustomer

Building, Deploying, and Running the Application

The general instructions for building, deploying, and running sample applications are provided in Building, Deploying, and Running Sample Applications. In reading this document, use the following application-specific variables for this application:

Follow this general procedure:

  1. Build the Application. The build file, build.xml, is in the app_dir directory, specifically, install_dir/samples/ejb/cmp/apps/cmpcustomer.
  2. Deploy the Application. The EAR file is install_dir/samples/ejb/cmp/apps/cmpcustomer/cmpcustomer.ear.
  3. Run the Application using the context root customer.

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