Skip Headers

Oracle Application Server Containers for J2EE User's Guide
10g (9.0.4)

Part Number B10322-01
Go To Documentation Library
Home
Go To Product List
Solution Area
Go To Table Of Contents
Contents
Go To Index
Index

Go to previous page Go to next page

2
Configuration and Deployment

This chapter demonstrates how to configure and execute OC4J as simply and quickly as possible. You installed OC4J with the Oracle Application Server installation.

Within OC4J, you can execute servlets, JSP pages, EJBs, and SQLJ. As an example of deploying an application to OC4J, this chapter describes how to configure the FAQ application demo.

This chapter includes the following topics:

OC4J Home Page Overview

Most of the configuration and management of your OC4J instance occurs off its OC4J Home Page. When you create an OC4J instance off of the Oracle Application Server Instance Home Page, it creates an OC4J Home Page for configuration and management of your OC4J instance. Each OC4J instance has its own OC4J Home Page.

Off the Application Server Control, you can drill down to any of the running OC4J instances by selecting the name of the instance (home, for example) in the System Components table. The Application Server Control displays the OC4J Home Page for that instance.

Figure 2-1 shows portions of the OC4J Home Page for the home instance.

Figure 2-1 Application Server Control OC4J Home Page

Text description of oemoc4j.gif follows.

Text description of the illustration oemoc4j.gif

The OC4J Home Page shows metrics on your OC4J instance and its applications. In addition, you can start, stop, and restart all OC4J processes configured to this instance.

From the OC4J Home Page, you can navigate to the following pages:

Applications Page

Figure 2-2 shows the Deployed Applications section. In this section, you can deploy applications using the Deploy EAR file or Deploy WAR file buttons. After deployment, you can modify configuration for each application. See "Deploying Applications" for more information.

Figure 2-2 Deployed Applications

Text description of home_dep.gif follows.

Text description of the illustration home_dep.gif

As an example, you can see how the FAQ application demo is configured and deployed to OC4J in "Configuring the FAQ Application Demo".

Administration Page

Figure 2-3 shows the Administration page. You can modify the following:

Figure 2-3 Administration Section

Text description of home_adm.gif follows.

Text description of the illustration home_adm.gif

Details for each of these options are covered in "Configuring OC4J Using Oracle Enterprise Manager".

Starting and Stopping OC4J

OC4J is installed with a default configuration that includes a default Web site and a default application. Therefore, you can start OC4J immediately without any additional configuration.

From the Oracle Enterprise Manager Web site, you can start, stop, and restart OC4J with one of the following methods:

OC4J automatically detects changes made to deployed applications and reloads these applications automatically. Therefore, you do not need to restart the server when redeploying an application. However, you may have to restart OC4J if you modify fields in any of the options off of the Administration page.

You can also start, stop, and restart using the DCM control command. See the Distributed Configuration Management Reference Guide for directions.

Testing the Default Configuration

Start OC4J with the defaults, as follows:

  1. From the Oracle Application Server Instance Page, start either the whole Oracle Application Server instance or--at least--the Oracle HTTP Server and OC4J components. To start, click the Start All button for the Oracle Application Server instance or select the components and click the Start button.

  2. Test OC4J by specifying the following from a Web browser:

    http://<ohs_host>:7777/j2ee/j2ee-index.html
    
    
    

    Substitute the name of the host where the OHS is installed for <ohs_host>.

  3. Test a servlet deployed in OC4J during installation by specifying the following in a Web browser:

    http://<ohs_host>:7777/j2ee/servlet/HelloWorldServlet
    
    
    

    This command returns a "Hello World" page. The HelloWorldServlet is automatically deployed with the OC4J installation.


    Note:

    The examples and URLs in this guide use port 7777, which is the default port for the OHS Web listener. If you change the default port number of the OHS, then specify the new port number after the hostname, as follows:

    http://<ohs_host>:<ohs_port>/j2ee/


Creating the Development Directory

When developing your application, Oracle recommends that you use consistent and meaningful naming conventions. As an example, you could develop your application as modules within a directory named after your application. All the subdirectories under this directory could be consistent with the structure for creating JAR, WAR, and EAR archives. Thus, when you have to archive the source, it is already in the required archive format. Figure 2-4 demonstrates this structure.

Figure 2-4 Development Application Directory Structure

Text description of config2.gif follows

Text description of the illustration config2.gif

Consider the following points regarding Figure 2-4:

Configuring the FAQ Application Demo

This section describes how to configure the FAQ J2EE demo application, which provides support for managing Frequently Asked Questions (FAQs) and storing/retrieving these FAQs from an Oracle database. You must have a working Oracle database and an OC4J installation. You should use this installation for demonstration purposes only and not in a production environment.

FAQs are broadly categorized into Specialization Areas. Each Specialization Area is further sub-categorized into Topics. Each FAQ can be associated with multiple Specialization Areas, where each area has one or more Topics associated with them.

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

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

This application is a J2EE 1.3 compliant application, developed utilizing the following technologies:

The following sections detail how to configure and deploy the FAQ demo application. In addition, the last section demonstrates how these steps relate to any application that you may wish to configure and deploy to OC4J:

Environment Setup for FAQ Demo

In order to execute the FAQ demo, you must modify the back-end database to contain tables that the demo uses.

Oracle Database

Add the FAQ user and tables, as follows:

  1. Add the faq user with password of faq in your database.

  2. Create the database tables for the FAQ demo by executing the SQL table creation script CreateTables.sql script, which is located at <FAQApp_home>/faq/sql/CreateTables.sql or can be downloaded with the rest of the FAQ application from OTN in the FAQApp.zip file.

    In an Oracle database environment, you can execute the SQL script through SQL*Plus, connecting to the database and schema where you want the tables to be installed 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, and so on.

OC4J System Configuration for FAQ Demo

In order for the FAQ demo to execute properly, the following system modification must be implemented:

The directions for each of these steps are covered in the following sections:

Data Source Configuration

In order to execute the FAQ application, you must have an Oracle database with the corresponding FAQ application database schema installed on it. The FAQ Application uses the default global data source named OracleDS that ships with the application server, which must be configured so that it connects to the database in which you created the FAQ tables.


Note:

An I/O exception is thrown if you do not update the global OracleDS data source appropriately.


  1. Navigate to the OC4J Home Page on the Oracle Enterprise Manager Web site.

  2. Select the Administration tab at the top of the page.

  3. Select Data Sources under the Application Defaults section. The default application is the automatic parent of each application and it holds global configuration for all deployed applications, such as the data sources used. You are going to modify the default data source that the FAQ application uses.

  4. For the OracleDS data source, click the Edit button. This brings up the configuration information for this data source. Modify the JDBC URL, driver, username, and password to point to your back-end database.

    When finished, click the Apply button.

If your back-end database uses the thin JDBC driver, is located at myhost:1521:ORCL, and uses the username/password of faq/faq, then the j2ee/home/config/data-sources.xml file is modified to point to the database at the URL of jdbc:oracle:thin:@myhost:1521:ORCL, as follows:

<data-source
  class="com.evermind.sql.DriverManagerDataSource"
  name="OracleDS"
  location="jdbc/OracleCoreDS"
  xa-location="jdbc/xa/OracleXADS"
  ejb-location="jdbc/OracleDS"
  connection-driver="oracle.jdbc.driver.OracleDriver"
  username="faq"
  password="faq"
  url="jdbc:oracle:thin:@myhost:1521:ORCL"
  inactivity-timeout="30"
/>

See Chapter 4, "Data Sources Primer" for more information on data sources.

Security Configuration

The FAQ demo uses Oracle Application Server Java Authentication and Authorization Service for authentication and user access control capabilities.

  1. Select the Administration tab at the top of the OC4J Home Page.

  2. Select Security under the Application Defaults section. The default configures global configuration for all deployed applications. You are going to add the user that the FAQ application uses to the jazn.com realm.

  3. On the Security page, scroll down to the Users section

  4. Click Add User. A configuration screen appears that allows you to add information about the new user. Supply the following information:

    • Name and password of the user

    • Check the checkbox next to the jazn.com/users realm

    When finished, click the Apply button.

Alternatively, an application user is added to the default jazn.com realm through the jazn.jar command line tool, as follows:

> java -jar jazn.jar -adduser jazn.com <username> <passwd>
> java -jar jazn.jar -grantrole users jazn.com <username>

The previous adds your user (given the username and password) to the jazn.com realm and then grants the users role to the new user. See the Oracle Application Server Containers for J2EE Security Guide for complete information on using OracleAS JAAS Provider as your security provider.

Deploy the FAQ Demo

Download the FAQ demo application from OTN in the FAQApp.zip file.

  1. Unzip this file to a working directory, which is referred to as <FAQApp_Home>.

  2. Navigate to the OC4J Home Page on the Oracle Enterprise Manager Web site.

  3. Select the Applications tab at the top of the screen.

  4. Click on the Deploy EAR File button. This starts the application deployment wizard.

  5. Provide the EAR file and the name of your application in the Select Application page. Click the Browse button to find the FAQApp.ear file that you unzipped on your system. Type "FAQApp" in the application name field. Click the Continue button.

  6. Provide the URL mappings for the servlet context on all Web modules in the FAQ application. The FAQApp demo contains a Web module, which should be mapped to the /FAQApp servlet context. Type "/FAQApp" in the URL mapping field and click the Next button.

  7. At this point, the FAQApp demo does not need any additional configuration through the wizard. You can jump to the Summary page by clicking Finish.

  8. Read the summary of the FAQApp application deployment. Click the Deploy button to complete the application deployment.

  9. On the OC4J Home Page, select "FAQApp" in the Name column of the Applications section. This shows the configuration and all deployed modules of the FAQApp demo application. If the OC4J server is started, the application is automatically started.

  10. Execute the FAQApp application in your browser by accessing the OHS, where the default port is 7777.

    http://<ohs_host>:7777/FAQApp 
    
    

    The FAQApp screen appears.

Deployment Details Explained

Although the development of J2EE applications is standardized and portable, the non-application (server) configuration is not. The necessary server configuration depends on the services that your application uses. For example, if your application uses a database, you must configure its DataSource object.

For basic applications, such as the FAQ demo, you would configure the following:

To create and deploy simple J2EE applications, perform the following basic steps:

Basic Step FAQ Application Step Description
  1. Create or obtain the application.

Download the FAQApp.zip from OTN

  1. Make any necessary server environment changes.

Set the JAVA_HOME variable

  1. Modify any global configuration modifications.

Modified the default data source, OracleDS, and added a user to the default OracleAS JAAS Provider security.

  1. Provide the application deployment descriptors.

The deployment descriptors, such as web.xml and ejb-jar.xml, are provided in the FAQApp.EAR file. For your application, you may have to create these XML files.

  1. Update the application standard J2EE application descriptor file.

The application.xml file is included in the FAQApp.EAR file. For your application, you may have to create this XML file.

  1. Build an EAR file including the application--if one does not already exist.

If you want to modify the FAQ demo, modify within the src directory, and use ANT to build an EAR file.

  1. Register the application in the appropriate server XML files.

The application is registered when you deploy the application through the deployment wizard.

The following steps describe what modifications to make to deploy the FAQ demo application into OC4J.


Note:

Displays of the screens for each step of the deployment wizard are shown in "Deploying Applications".


  1. We asked you to download the FAQ demo application from the Oracle OTN site.

  2. Make any necessary server environment changes. You must set the JAVA_HOME variable to the base directory of the Java 2 SDK.

  3. Modify the global configuration of Oracle Application Server:

    1. Configure the OC4J DataSource for an Oracle database. Modify the default data source, OracleDS, to point to your back-end database, with the correct URL, username, and password.

    2. Add the user to the jazn.com realm.

  4. You can modify the FAQ demo application and rebuild it using the ANT command. You must install ANT as it is not provided with OC4J. To rebuild the FAQ demo, execute the following in the <FAQAPP_Home> directory:

    ant all
    
    

    The ANT build.xml is included in the FAQ ZIP download. To learn more about the ANT file, go to the following Jakarta site:

    http://jakarta.apache.org/ant/
    
    
  5. Deploy the FAQApp application with the Oracle Enterprise Manager deployment wizard. When you deploy, the wizard asks for information that is necessary to register the application, such as the name of the application and the Web context.

  6. Using the Oracle Enterprise Manager, start OC4J. For a complete description of all the OC4J starting options, see "Starting and Stopping OC4J".

  7. Open your Web browser and then specify the following URL:

    http://oc4j_host:7777/FAQApp
    

Deploying Applications

This section describes how to deploy a J2EE application to the OC4J server. When you deploy an application using the deployment wizard, the application is deployed to the OC4J instance and any Web application is bound to a URL context so that you can access the application from OC4J.

To deploy your application, drill down to the OC4J Home Page and scroll to the Deployed Applications section. Figure 2-2 shows this section.


Note:

You can also deploy simple applications with the dcmctl command. See the Distributed Configuration Management Reference Guide for directions.


Basic Deployment

Your J2EE application can contain the following modules:

Archive the JAR and WAR files that belong to an enterprise Java application into an EAR file for deployment to OC4J. The J2EE specifications define the layout for an EAR file.

The internal layout of an EAR file should be as follows:

Figure 2-5 Archive Directory Format

Text description of configa.gif follows

Text description of the illustration configa.gif

Archive these files using the JAR command in the <appname> directory, as follows:

% jar cvfM <appname>.ear .

Note that the application.xml file acts as a standard J2EE application descriptor file.

Both of these buttons start an application deployment wizard, which guides you through deploying an application. In the case of the WAR file, the application.xml file is created for the Web application. Whereas, you must create the application.xml file within the EAR file. Thus, deploying a WAR file is an easier method for deploying a Web application.


Note:

You must still provide configuration for J2EE services, such as data source and security configuration.


Select Application

Figure 2-6 shows the first page, which enables you to provide the following:

Figure 2-6 Designate EAR File

Text description of first.gif follows.

Text description of the illustration first.gif

When the application is deployed, the information in this step enables the following:

  1. Copies the EAR file to the /applications directory.

  2. Creates a new entry in server.xml for the application, as follows:

    <application name=<app_name> parent="applicationWithCommonClasses" 
    path=<path_EARfile> auto-start="true" /> 
    
    
    

    where

    • The name variable is the name of the application you provided.

    • The parent is the name of the optional parent application. The default is the global application. Children see the namespace of its parent application. This setting is used to share services, such as EJBs among multiple applications.

    • The path indicates the directory and filename where the EAR file is deployed.

    • The auto-start variable indicates if this application should be automatically restarted each time OC4J is restarted.

    For a description of the elements in server.xml, see "Elements in the server.xml File".

Click the Continue button to go to the next step in the wizard deployment process. The wizard uploads your EAR file and examines the application. Based on your configuration files and deployment descriptors, the wizard dynamically presents only the configuration screens your application needs. These screens are a subset of the steps presented in the following sections:

Provide The URL Mappings For All Web Modules

Map any Web modules in your application to a specific URL for its servlet context. When you try to access any Web applications, you provide the host, port, and Web context.

For all Web modules, your URL mapping for this module includes the URL you bind in this screen. Thus, for the URL http://<host>:<port>/url_name, provide /url_name in the URL mapping screen of the wizard.

Figure 2-7 Configure URL Mapping for Web Modules

Text description of second.gif follows.

Text description of the illustration second.gif

Click the Next button to go to the next step in the wizard deployment process.

IIOP Stub Generation

The EJBs in your application can have IIOP stubs generated by selecting Generate IIOP Stubs. See the "Interoperability and RMI Tunneling" chapter in the Oracle Application Server Containers for J2EE Services Guide for information on IIOP stubs.

Figure 2-8 Generate IIOP Stubs

Text description of iiopstub.gif follows.

Text description of the illustration iiopstub.gif

Click the Next button to go to the next step in the wizard deployment process.

Provide Any Resource Reference Mappings

Map any references resources in your application, such as data sources or mail queues, to physical entities currently present on the OC4J container. Note that if you need a specific resource, you must have already added this to the OC4J container before you deploy your application in order for you to match them in this step.

For most applications, the resource reference you must designate is the data source JNDI name. This screen does not configure the data source information, it only designates an already configured data source or a data source that you will be configuring later. Designate the JNDI location name of the data source that the application will be using.

Figure 2-9 Map Resource References

Text description of config6.gif follows

Text description of the illustration config6.gif

If you have any MDBs in your EAR file, you may be required to add information about the subscriptions or topics. If you are defining DataSource objects for CMP entity beans, you are given the option to add a JNDI location for those DataSource objects.

Figure 2-10 Map Resource References for Entity Beans and MDBs

Text description of st4_mdb.gif follows.

Text description of the illustration st4_mdb.gif

Click the Next button to go to the next step in the wizard deployment process.

Specify Any User Manager

You can specify what User Manager to use for security. For complete security, we recommend that you choose the OracleAS JAAS Provider XML User Manager.

Figure 2-11 User Manager Choices

Text description of usermgr.gif follows.

Text description of the illustration usermgr.gif

As Figure 2-11 demonstrates, you must already have your User Manager set up and configured. Most of the entries requires an XML file that designates the security roles, users, and groups for your security mappings.

For more information on security and User Managers, see the Oracle Application Server Containers for J2EE Security Guide.

Publish OracleAS Web Services

Publish any OracleAS Web Services defined in your application. This feature requires the UDDI registry. OracleAS Web Services are not installed with a core install.

If you have defined any OracleAS Web Services, they are shown in the following screen:

Figure 2-12 Publish Web Services

Text description of sixth.gif follows.

Text description of the illustration sixth.gif

If you want to publish these OracleAS Web Services, then click on the Publish button. This leads you through the process of publishing your OracleAS Web Services. When finished, it brings you back to this screen.

Click the Next button to go to the next step in the wizard deployment process.

Deployment Review

At this point, you will receive a review of your application deployment modules and configuration, as follows:

Figure 2-13 Review Panel

Text description of seventh.gif follows.

Text description of the illustration seventh.gif

In order to deploy this application, click on the Deploy button. A message will be displayed that tells you that your application deployed.

Post-Deployment Application Modifications

You can modify any fields and add additional configuration by returning to the OC4J Home page, select the application name in the Applications section. This brings you to a screen with the details of the deployed application.

From within this screen, you can view the Web and EJB modules. In addition, you can add and modify application-specific properties, resources, and security options in the Administration section. It is in this Administration section, that you can add application-specific data sources or security groups or users mentioned in the deployment wizard.

Recovering From Deployment Errors

If the deployment process is interrupted for any reason, you may need to clean up the temp directory, which by default is /var/tmp, on your system. The deployment wizard uses 20 MB in swap space of the temp directory for storing information during the deployment process. At completion, the deployment wizard cleans up the temp directory of its additional files. However, if the wizard is interrupted, it may not have the time or opportunity to clean up the temp directory. Thus, you must clean up any additional deployment files from this directory yourself. If you do not, this directory may fill up, which will disable any further deployment. If you receive an Out of Memory error, check for space available in the temp directory.

To change the temp directory, set the command-line option for the OC4J process to java.io.tmpdir=<new_tmp_dir>. You can set this command-line option in the Server Properties page. Drill down to the OC4J Home Page. Scroll down to the Administration Section. Select Server Properties. On this page, Scroll down to the Command Line Options section and add the java.io.tmpdir variable definition to the OC4J Options line. All new OC4J processes will start with this property.

Undeploying Web Applications

You can remove a J2EE Web application from the OC4J Web server by selecting the application in the Applications section of the OC4J Home Page (see Figure 2-2) and clicking the Undeploy button. This command removes the deployed J2EE application and results in the following:


Go to previous page Go to next page
Oracle
Copyright © 2002, 2003 Oracle Corporation.

All Rights Reserved.
Go To Documentation Library
Home
Go To Product List
Solution Area
Go To Table Of Contents
Contents
Go To Index
Index