Eclipse Corner Article

WTP Tutorials - Deploy Web Applications to the Oracle Application Server

Summary
This tutorial will step you through the details of deploying a Web Application to the Oracle Application Server Containers for J2EE (OC4J).

By Raghu Srinivasan, Oracle Corporation.
October 27, 2005


Introduction

The Eclipse Web Tools Platform project release 1.0 M8 has added support for deploying Web Applications to the Oracle Application Server Containers for J2EE (OC4J). This tutorial will step you through the details of installing and configuring the Oracle Application Server Container for J2EE (OC4J) and deploying a Web Applications from the Eclipse Web Tools Platform to the Oracle Application Server.

Getting Started

This section will walk you through the software that you need to download, install and configure. Following is the list of software you will need to install:

Java 2 Platform, Standard Edition(J2SE) 1.4

You must first install the Jaav2 Platform, Standard Edition (J2SE) version 1.4.2. You can get the latest release of J2SE 1.4.2 from the Sun's web site.. Install the JDK.

Make a note of the folder in which you install J2SE. This will be required later in the tutorial.

Eclipse and WTP

You need to download and install the WTP 1.0 release build. Download the WTP all-in-one package. It includes the complete set of software to start using wtp immediately.

Oracle Application Server Containers for J2EE (OC4J)

And finally, you need to download, install and configure the Oracle Application Server Containers for J2EE (OC4J). The server adapter in the WTP 1.0 release is certified for the OC4J 10g (10.1.3.0.0) release.

The Oracle Application Server Containers for J2EE (OC4J) zip distribution provides a complete J2EE 1.4 server environment, distributed as a simple zip file. You can download the server from the Oracle download site.

Extract OC4J

Extract the oc4j_extended_101300.zip file using any archive utility which handles zip files, including the jar utility in the J2SE.

Initialize OC4J

You need to start the OC4J instance once to set the password for the OC4J administrator account. The username for this account defaults to "oc4jadmin". Set the following environment variables:

For example, if J2SE was installed in C:\j2sdk1.4.2_09 and oc4j_extended.zip was extracted to C:\Oracle\oc4j the environment variables should be set as follows: Start the server.From the bin directory of oc4j, issue the following command: You should see the following messages in the console. You will be prompted to enter the password for the OC4J administrator account.

Make a note of the password.

Stop the server.From the bin directory of oc4j, issue the following command: This completes the installation and configuration of all the required software.

The following information will be required in the later part of this tutorial

Run a Web Application on the Oracle Application Server

In this section you will build a simple JSP Web Application, deploy and run it on the Oracle Application Server. Following is the list of tasks:

Create a Server

Launch Eclipse.
Open the J2EE perspective; select Window > Open Perspective > Other menu and in the resulting dialog, choose J2EE. The J2EE perspective includes the Servers view, which is the focus for the rest of the tutorial.
You will also need the Console view to see the output of the Server. Select Window > Show View > Console menu.

From a command prompt, you can launch Eclipse using the following command:
$EclipseInstallFolder\eclipse\eclipse.exe -vm "$J2SEInstallFolder\bin\javaw.exe" -clean -data "$WorkspaceFolder"
where $EclipseInstallFolder is folder where you installed Eclipse and $WorkspaceFolder is where you want to create new or access an existing Eclipse workspace.

Figure 1 shows the Eclipse Workbench displaying the J2EE perspective. Note the Servers view and the Console view.

Figure 1. The Eclipse Workbench with the Servers view and the Console view.
The Eclipse Workbench

Register the JDK you installed with Eclipse.

For the field JRE home directory , point it to the root folder of the J2SE install and not the jre sub-folder.

Next you register the Oracle Application Server runtime and create a server.
Right-click in the Servers View and select New > Server menu. This launches the New Server wizard.

Figure 2 shows the New Server Wizard with the Generic Oracle OC4J Standalone 10.1.3 DP4 Runtime selected.

Figure 2. The New Server Wizard
The New Server Wizard

  1. In the Define a New Server panel, Select Oracle > Generic Oracle OC4J Standalone Server 10.1.3 DP4. Click Next.
  2. In the Define a new Generic Oracle OC4J Standalone 10.1.3 DP4 Runtime panel,

    Figure 3 shows the panel to register the Generic Oracle OC4J Standalone 10.1.3 DP4 Runtime.

    Figure 3. Register the Generic Oracle OC4J Standalone 10.1.3 DP4 Runtime
    Register runtime

  3. In the Create a new Generic Oracle OC4J Standalone 10.1.3 DP4 server panel,
You will see the Oracle OC4J Standalone 10.1.3 DP4 Preview server in the Servers view. Right-click on the server and select Start to start the server. This starts the server and displays the output in the Console view.

Figure 4 shows the Oracle OC4J Standalone 10.1.3 DP4 Preview server in the Servers view.

Figure 4. Oracle OC4J Standalone 10.1.3 DP4 Preview server in the Servers view
Oracle OC4J Standalone 10.1.3 DP4 Preview server

Build a JSP Web Application

You will now build a simple JSP application that you will then run on the server. The Eclipse WTP web site has a several tutorials that can help you build sophisticated applications using the WTP tools.

The first step to build a JSP application is to create a Dynamic Web Project.

This will create the project.

Next, you will create a JSP page.

You are ready to run the page on the server.

Deploy and Run the Web Application

Right-click on the jsp file, index.jsp, in the ProjectExplorer. Select Run As > Run on Server menu.
In the Run On Server dialog, ensure that the server, Oracle OC4J Standalone Server v10.1.3 DP4 Preview, is selected. Click on Finish.
The Eclipse WTP tool will now do the following:

The Console view displays the log tracking the progress of the deployment.

Figure 5 shows the application running on Oracle OC4J Standalone 10.1.3 DP4 Preview server.

Figure 5. Running the application on Oracle OC4J Standalone 10.1.3 DP4 Preview server.
Running the application

Conclusion

In this tutorial you have learned to configure the Eclipse Web Tools Platform Project to deploy and run a web application on the Oracle Application Server. The WTP web site has articles and tutorials that explain the numerous tools provided in WTP to help you build and deploy web applications. The Oracle web site has extensive resources to help you explore the capabilities of the Oracle Application Server.

References

  1. WTP Articles and Tutorial.
  2. Oracle Application Server.