Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

...

A current DayTrader project implementation in Apache Geronimo contains several JPQL queries. These can easily be converted to JPA Criteria API queries. A sample with this conversion can be created to run on either the Apache Geronimo server or the WebSphere Application Server with the built-in Derby database.

Downloading DayTrader

You must have Subversion installed in order to download the DayTrader implementation.Subversion can be downloaded from http://subversion.apache.org/packages.html. Use the 2.1.3 version of DayTrader for this sample. Follow the following steps:

...

From the DayTrader/branches/2.1.3 directory, type "mvn clean install" to build the project.

Setting up Eclipse

First install eclipse by going to http:/www.eclipse.org and downloading a version of it. These instructions assume version 3.5. Unzip the downloaded file into a directory. You can start eclipse by running eclipse.exe in the eclipse directory.

Next install subclipse, the Subversion Eclipse Plugin:

  1. In Eclipse, go to Help -> Install New software
  2. Click on Add button - Enter Subclipse for Name and http://subclipse.tigris.org/update_1.6.x for location
  3. Select the Subclipse Plugin and click Next -> Next
  4. Read and accept the license and click Finish

Generate eclipse files for the DayTrader project. From the DayTrader/branches/2.1.3 directory, type "mvn eclipse:eclipse"

Set the M2_REPO classpath variable in Eclipse:

  1. Go to Window -> Preferences -> Java -> Build Path -> Classpath Variables
  2. Add a new variable called M2_REPO, set to the maven repository directory..

Import DayTrader projects into Eclipse.

  1. From Eclipse, Click on File -> Import...
  2. Under the General folder, select Existing Projects into Workspace and click on Next.
  3. Enter the root directory of DayTrader/branches/2.1.3
  4. Select all projects and click Finish

(Note: If you see errors that say "java.util.zip.ZipException: error in opening zip file", ignore them for this exercise.)

Apply the DayTrader Patch

The following patch can be applied using a system or downloaded patch utility. (For example, you can get a patch utility for Windows from http://gnuwin32.sourceforge.net/packages/patch.htm.)

for Geronimo - daytrader_geronimo.patch

for WebSphere - daytrader_websphere.patch

Download the appropriate Download this patch and go to the DayTrader/branches.2.1.3 directory to apply it. For example, with the patch utility mentioned above, you can type:

...

You can also Apply an Eclipse Patch

Re-create the DayTrader ear file

From the DayTrader/branches/2.1.3 directory, type "mvn clean install" to build the project.

Run DayTrader on Geronimo

...

  1. Click on Deploy New
  2. For Archive, browse to DayTrader/branches/2.1.3/modules/ear/target/daytrader-ear-2.1.3.ear
  3. For Plan, browse to DayTrader/branches/2.1.3/plans/dayTrader-derby-plan.xml
  4. Check Start app after install
  5. Click on Install

Re-start the server.

Make sure that the system module, org.apache.geronimo.configs/axis-deployer/2.1.5/car, is running.

...

  1. Go to http://<host>:8080/daytrader/
  2. Click on the Configuration tab and click on (Re)-create DayTrader Database Tables and Indexes
  3. Click on the Configuration  tab and click on (Re)-populate DayTrader Database
  4. Click on the Trading & Portfolios tab, login, and start trading

Run DayTrader on WebSphere

This writeup assumes some familiarity with WebSphere. Also, the script that is provided assumes a local unmanaged node with a single server.

At a minimum, the WebSphere Application Server must be at version 7.0.0.9. You must also have installed the Feature Pack for OSGi Applications and Java Persistence API 2.0. Make sure you have a profile that is augmented for JPA 2.0 function.

Download the following jython script. This script is used to configure the objects needed by DayTrader (data sources, JMS queues and topics) and install the application.

daytrader_singleServer.py

Within the bin directory of the augmented profile:

  1. Start the server.
  2. Run the script using the following command: "wsadmin -f <location of daytrader_singleServer.py> <script options>". You can display the list of available script options by specifying the option "--help".
  3. Re-start the server.

Run DayTrader

  1. On a web browser, go to http://localhost:<application port>/daytrader/ (The default application port is 9080. But, you may have a different one if you created a new profile.)
  2. Click on the Configuration tab and click on (Re)-create DayTrader Database Tables and Indexes
  3. Click on the Configuration  tab and click on (Re)-populate DayTrader Database
  4. Click on the Trading & Portfolios tab, login, and start trading