The Java Adventure Builder Reference Application v1.0
(Adventure Builder) is a blue print application made available by Sun Microsystems that demonstrates the latest J2EE
1.4 technologies. You can find more info about the application at http://java.sun.com/blueprints/code/adventure/1.0/docs/index.html.
Enterprise JavaBeans (EJB 3.0) and Web services metadata greatly simplifies J2EE service development. Oracle has migrated the Java Adventure Builder 1.0.1 to use EJB 3.0 and Web services metadata to demonstrate its support for EJB 3.0 and Web services metadata.
It should be noted that Oracle is making this updated application available to demonstrate ease of development with EJB 3.0 and Web services metadata and it should not be considered as either replacement for the J2EE 1.4 blueprint application or the blueprint application for EJB 3.0 and Web services metadata.
This document describes the changes made by Oracle to use EJB 3.0 and Web services metadata. It also includes instructions to (re)build the application and deploy the modified Adventure Builder applications on Oracle Application Server 10g 10.1.3.
The Java Adventure Builder application consists of six modules:
Order Processing Center
Activity Supplier
Airline Supplier
Bank
Lodging Supplier
These modules all have have EJBs modules -- covering Entity beans, MDBs and stateless EJB web services exposed
with JAX-RPC end-points to process and track orders.
Consumer WebSite
The ConsumerWebSite is the Adventure Builder web module which provides a web interface to
search for and create orders for Adventure packages. This web module uses Stateless EJB
2.1 web services to submit and track the status of placed adventure orders.
After completing this How-to you should be able to:
Deploy the Java Adventure Builder Reference application
version 1.0.1 updated to use EJB 3.0 and WS Metadata -- on OC4J
Build yourself an adventure by running the completed application
Migration Overview
The primary objective of migrating Java Adventure Builder to utilize EJB 3.0 and Web services metadata was as an exercise to determine to what extent metadata annotations make application development simpler, and to validate usability of EJB 3.0 and Web services metadata. There was no attempt to redesign the object or data model for the applications.
The Consumer Website module has been updated to use EJB 3.0 persistence instead of JDBC DAO.
The server side components Order Processing Center, Bank and Supplier modules have been migrated to use EJB 3.0 Session Beans, Message Driven Beans and the Persistence API. All web services have been migrated to use Web services metadata.
The following table summarizes the migration work for each modules:
Module Name
Technology Used
Consumer Website
EJB 3.0 persistence API with O-R Metadata
Order Processing Center (OPC)
EJB 3.0 Persistence API
EJB 3.0 SLSB, MDB, Dependency Injection
Web services metadata for SLSB SEI
Bank
EJB 3.0 SLSB
Web services metadata for SLSB SEI
Activity Supplier
EJB 3.0 Persistence API
EJB 3.0 SLSB, MDB, Dependency Injection
Web services metadata for SLSB SEI
Airline Supplier
EJB 3.0 Persistence API
EJB 3.0 SLSB, MDB, Dependency Injection
Web services metadata for SLSB SEI
Lodging Supplier
EJB 3.0 Persistence API
EJB 3.0 SLSB, MDB, Dependency Injection
Web services metadata for SLSB SEI
The migrated application also demonstrates that both annotations and deployment descriptors can be used together in EJB 3.0 modules, and further, that EJB 3.0 and EJB 2.1 are interoperable.
how-to-adventurebuilder-ejb3wsm.html- this document
config/ : includes sample configuration files for OC4J for JMS and DB configuration
scripts/
script to create tables
in an Oracle Database
Setting Up the Application
Using an Oracle Database
1) Configure the Oracle database prior to configuring OC4J or deploying the application using the supplied SQL script scripts/oracle.sql . This script creates the table and necessary data for using the application. If you are using SQL*Plus with Oracle database you can use the following command, assuming you you already have a user created named ab .
The original Adventure Builder application uses auto-create table features for CMP 2.1 entity beans. We do not think is a good practice so we have provided scripts to explicitly create the schema for the OPC and supplier tables.
2) Create a Data Source on OC4J to connect to the user in which the necessary tables and data are loaded. The JNDI Location of the new data source should be jdbc/adventure/AdventureDB.
To create this new data source you can either:
Use Oracle Application Server Control console to create the DataSource -- we recommend you read this
article which explains how to create a new data source with ASC.
Manually update
the %ORACLE_HOME%/j2ee/home/config/ data-sources.xml file with
the following entries to construct the datasource. Change the database connection details to match your environment:
Adventure Builder relies on a number of resources to be provided by a J2EE container. These resources must be configured on OC4J before the application can be deployed and executed.
Mail Server
To enable the application to generate emails on the submission and completion of orders, you have to configure a mail-session resource on OC4J.
1) Edit the %ORACLE_HOME%/j2ee/home/config/application.xml file and add an entry for the mail server you wish to use. For example, your application.xml would have the following entry:
Adventure Builder uses message queues to transmit order and fulfillment details. Several JMS queues must be configured for Adventure Builder to use. You can use AS Control to create these message destinations.
Optionally you can manually edit the %ORACLE_HOME%/j2ee/home/config/jms.xml file to configure Queues and Queue Connection Factories. You may update this file with the following entries:
<queue name="jms/opc/WebServiceBrokerQueue" location="jms/opc/WebServiceBrokerQueue">
<description>Adventure Builder Web Service Broker Queue</description>
</queue>
Configure the Environment
Ensure the following environment variables are defined:
%ORACLE_HOME% - The directory where you installed OC4J.
%JAVA_HOME% - The directory where you installed the J2SE 5.0
%PATH% - includes %ORACLE_HOME% /ant/bin
Start the Server
An OC4J 10g 10.1.3 instance must be running. Start the container using the following command:
%ORACLE_HOME%/bin/oc4j -start
Deploying the Application
Please check to make sure that the following properties are configured correctly in the ant-oracle.properties file located in the root of the sample's distribution. If necessary, modify these variable to the proper values for you environment:
oracle.home - the root directory of oracle installation. Defaults to ORACLE_HOME env variable.
java.home - the root directory of JDK installation. Defaults to JAVA_HOME env variable.
oc4j.host - the hostname of the platform on which the OC4J instance is running. Defaults to localhost.
oc4j.http.port - the port on which the OC4J HTTP listener is listening. Defaults to 8888.
oc4j.admin.port - the port on which the OC4J administration processor is listening. Defaults to 23791.
oc4j.admin.user - the name of the OC4J administrator. Defaults to "oc4jadmin".
oc4j.admin.password - the password for the OC4J administrator. Defaults to "welcome".
oc4j.binding.module - the name of the HTTP web site to which the deployed application is bound. Defaults to "default-web-site".
Ensure $ORACLE_HOME/ant/bin is included in your PATH environment variable.The deployment of the Adventure Builder application is done using following command from a command prompt in the root directory of the sample:
>ant
Executing the default all target of the supplied build.xml performs the following steps:
deploys the different ear files
for the various application components:
ActivitySupplier.ear
AirlineSupplier.ear
Bank.ear
ConsumerWebsite.ear
LodgingSupplier.ear
OPC.ear
Binds the web module in ConsumerWebsite to the context-path of "/ab"
Running the Application
Once the application has been successfully deployed using the Ant build script you can test the application by accessing the consumer website application using the URL: http://localhost:8888/ab/
Summary
In this document you should have:
Understood what the Adventure Builder Application is.
Understood the changes made by Oracle to use EJB 3.0 and Web services metadata.