Sun Java System logo     
Duke's Bookstore Sample Application



Duke's Bookstore Sample Application


This document describes how to utilize the Duke's Bookstore sample application in conjunction with Sun Java (tm) System Application Server 7.

This sample application document contains the following sections:



Overview

This sample is part of J2EE Reference Implementation, and is explained in the J2EE Tutorial. To reference the J2EE Tutorial, go to http://java.sun.com/j2ee/tutorial (under Web Technology).

The Duke's Bookstore sample application illustrates the tasks involved in programming using web Technologies. Dukesbank application allows users to retrieve available books from a database table, displays details of the book, add and remove books to a shopping cart and check out the books. The Duke's Bookstore example showcases different web technologies in the following two applications:


Directory Structure

The two bookstore samples and their associated files are kept under the samples/webapps/bookstore directory
File

Description

bookstore1

All files relating to bookstore1 sample.

bookstore2

All files relating to bookstore2 sample.

docs

docs for bookstore1 and bookstore2.

common

common files, like sql.

Each bookstore sample has build.xml and deployment descriptors under the src directory. (e.g. bookstore1/src or bookstore2/src).



Compiling and Assembling the Application



This section contains instructions to build and assemble the Duke's Bookstore sample application.

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

  • To rebuild the entire application from scratch, do the following:

    • Go to the bookstore/bookstore1 (or bookstore2)/src directory

    • Execute the command asant core

  • To clean up the sample application project area, do the following:

    • Go to the bookstore/bookstore1 (or bookstore2)/src directory

    • Execute the command asant clean.

      This will will delete the assemble and build directories.



Deploying the Sample Application

In this section, you will learn how to deploy the Duke's Bookstore sample application.

To deploy the application, do the following:

  • Start your database server (PointBase).

  • Go to the bookstore/bookstore1 (or bookstore2)/src directory

  • Deploy the sql datasource.

    Please note that all two bookstore applications share the same jdbc-DataSource. To create the datasource type asant setup_pb. This creates the datasource for pointbase database. To run the sample on Oracle please refer to Deploying in Oracle section below. Do not create this datasource for each bookstore application. For this reason, asant all does not create sql datasource.

  • Execute the command asant deploy. This deploys the bookstore application.

To undeploy the application, do the following:

  • Go to the bookstore/bookstore1 (or bookstore2)/src directory

  • Execute the command asant undeploy

  • To undeploy the jdbc datasource, execute the command asant undeploy-sql


Deploying in Oracle

To deploy the sample in Oracle, please follow the steps outlined below. Note that the steps to Deploy Bookstore application is a special case of what is outlined in the document (How to run samples with Oracle database server) document.

  • Set up the database, create bookstore user and tables. Please refer to General settings of the oracle document.
  • Add the following target to build.xml.
    <target name="setup_ora" depends="setup_env, deploy_jdbc_resource_ora_common, reconfig"/>
  • Create jdbc connection pool and Data source. To do so, run
    asant setup_ora -Ddb.host=[db_hostname] -Ddb.port=[db_port] -Ddb.sid=[sid]
  • Deploy the application. Use asant deploy.


Running the Sample Application



In order to run the sample application, you must first do the following:

You are now ready to run the sample application by doing the following.

  • bookstore1: On your browser go to the url : http://<host>:<port>/bookstore1/enter

  • bookstore2: On your browser go to the url : http://<host>:<port>/bookstore2/enter

Each bookstore sample has build.xml and deployment descriptors under src directory. (e.g. bookstore1/src or bookstore2/src)

The following images are from running the bookstore1 sample.



Figure 1    Duke's Bookstore: "Start Shopping" link



Figure 2    Duke's Bookstore: Shopping Cart



Figure 3    Duke's Bookstore: Cashier


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 samples/webapps/bookstore/bookstore1/javadocs/index.html.



Troubleshooting



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

  • Check to see if the database is running.

  • To reset your database, run the command asant sql.

  • To redeploy the sample, please undeploy the sample first. Use the commands asant undeploy, asant clean and then asant all.



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

Last Updated August 12, 2002