Oracle Application Server Containers for J2EE (OC4J) 10g (10.0.3) Developer Preview -
JMX enabled FAQ Application

Date: 08/21/03

Demonstration Name
Description
Software Required
Downloading the Source Code
Notation
Configuration Instructions
Deployment Instructions
Running the Demonstration
Other Demonstrations of Interest

Demonstration Name

Oracle Application Server Containers for J2EE (OC4J) 10g (10.0.3) Developer Preview -
JMX enabled FAQ Application

Description

This JMX enabled FAQ application demonstrates support for managing Frequently Asked Questions (FAQs) and storing/retrieving them from an Oracle database. FAQs are broadly categorized into Specialization Areas. Each Specialization Area is further sub-categorized into Topics. A FAQ can be associated with multiple Specialization Areas which in turn have multiple Topics associated with them.

FAQs are of two types - Internal (to be published for internal users only) and External (to be published on external forums). Internal FAQs will include all external FAQs + internal FAQs.

Areas, Topics and FAQs are entered or updated in the database via Input/Update screens or via a corresponding Web service interface. Each Area, Topic and FAQ is uniquely identified by a primary key which is automatically generated by the system.

You can generate a list of FAQs (in HTML format) for a given Specialization Area for internal or external publication.

This application also contains an example of how to implement user defined MBeans and how to access them using a generic JMX console. In this particular case, the application implemented a series of operations that would help the FAQ application administrator perform certain tasks that are not allowed to a regular user (e.g. removing a Topic or a Specialization Area). You can access the application's administration console by clicking on the Administration tab.

This demonstration also shows how to write and access metrics using the Dynamic Monitoring Service or DMS, and how to send event notifications and register event listeners. The events of interest for this demo are the following: removeTopic, removeArea and removeFAQ. Each of these events triggers a notification that is read by all registered listeners. Some events reach all listeners, others are specific to a particular listener (by using filters). There are three MBeans registered for this demo:

The Administration MBean allows the user to access all the operations reserved for the application's administrator, such as remove Topic, DMS statistics, query operations, etc. The EventMonitor MBean allows the user to start and stop a generic event listener and a Topic event listener. The generic listener will listen to all remove events and it will print messages to the OC4J standard output, the Topic listener will only listen to Topic remove events, using a JMX event filter. You can also start a remote listener using a special client program provided with this demonstration. Please refer to Running the Demonstration for informations on how-to run the event client.

The DBHelper MBean allows the FAQ administrator to access a series of database maintenance operations: populate, clean and reset. The populate operation populates the database with pre-defined FAQ data. This data is located in a file called populate.data, which is provided by default with the application. However, the user can provide any other FAQ data file as long as each line uses the folloging format: question#answer#area#topic. If no parameter value is passed when calling populate, the default FAQ data file is used automatically. Finally, clean removes all FAQs, Areas and Topics from the database and reset calls clean first and then populate.

The FAQ Application is a J2EE application, developed utilizing the following technologies:

Software Required

In order to run this demo, the following software is required:

Downloading the Source Code

The source code for the JMX enabled FAQ Application demonstration can be downloaded from the Oracle Technology Network (OTN). The jmx_demos.zip file should be unzipped to a working directory, from this point forward referred to as FAQ_HOME.

Notation

FAQ_HOME - Location of the downloaded/extracted FAQ application demonstration.
JAVA_HOME - Location of the Java Development Kit (JDK) that will be used to compile the application.
ORACLE_HOME - Location of where the Oracle Application Server is installed.
J2EE_HOME - Location of the Oracle Application Server J2EE files (normally %ORACLE_HOME%/j2ee/home).

Configuration Instructions

Before you run the demonstration please ensure that the required components are up, running and configured appropriately. Use the following set of instructions to do this validation/configuration.

Database Configuration
Data source Configuration

Database Configuration

Create the application's database tables by running the SQL table creation script CreateTables.sql script located at %FAQ_HOME%/sql/CreateTables.sql.

In an Oracle database environment this can be done by running SQL*Plus, connecting to the database and schema where you want the tables to be installed (e.g. SCOTT/TIGER) and executing @CreateTables. Please refer to the Oracle database documentation for further instructions on how to use SQL*Plus, running install scripts, creating database users/schemas, etc.

Data Source Configuration

The FAQ Application relies on the default global data source named OracleDS that ships with the application server. In order for the FAQ Application to be able to access the database this global OracleDS data source must be configured in such a manner that it connects to the same database user/schema that has been used in the steps described in the Database Configuration section of this document. Please note that you will encounter an I/O Exception telling you that the data source connection couldn't be established in case you fail to update the global OracleDS data source appropriately.

Deployment Instructions

The following instruction describe how-to build and deploy the FAQ Application to a standalone instance of OC4J.

Build Instructions
Deploying to a standalone OC4J Instance

Build Instructions

The FAQApp application is designed to be compiled using the build tool Jakarta Ant.

1. Edit the file %FAQ_HOME%/common.xml using the editor of your choice to reflect the configuration changes:

a. JAVA_HOME - Location of the Java Development Kit (JDK) that will be used to compile the application
b. ORACLE_HOME - Location of where the Oracle Application Server is installed
c. J2EE_HOME - Location of the Oracle Application Server J2EE files

2. If using a standalone OC4J instance, edit the file %FAQ_HOME%/build.xml using the editor of your choice to reflect the following changes.

a. Update <property name="deploy.ormi" value="ormi://localhost" /> to reflect your host machine
b. Update <property name="deploy.username" value="admin" /> to relect your administrator account
c. Update <property name="deploy.password" value="welcome" /> to reflect your administrator password

3. Set the environment variable %JAVA_HOME% to the location of the JDK that will be used to compile the application

4. In the %FAQ_HOME% directory type the command:

> ant

If any errors occur generally this is because of configuration errors in step 1. Correct these and run until a successful build occurs.

Deploying to a standalone OC4J Instance

The application can be deployed to standalone OC4J instance by typing the command:

> ant deploy

in the %FAQ_HOME% directory and pressing return. Please refer to the Build Instructions for setup information.

Running the FAQ Demonstration

You can start the FAQ Application by browsing

You can start the JMX Adminstration console for the FAQ Application by browsing

Note: Both, the faq and the admin user are defined in the application's jazn-data.xml. Also note that the application's administrator does not have to belong to the OC4J administrators security group.

You can also start the OC4J JMX Adminstration console for OC4J by browsing

In order to run the JMX event client provided with this demonstration, execute the following command in the %FAQ_HOME% directory:

> ant jmxlistener

Other Demonstrations of Interest

Please refer to the Oracle Application Server OC4J/J2EE demo download area on OTN for further OC4J/J2EE related demonstrations.