blob: d798eb3737df041fda0767afa4f15a83d3b5859b [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta
http-equiv="Content-Type"
content="text/html; charset=windows-1252">
<title>WTP Tutorials - Deploy Web Applications to the Oracle Application Server/title&gt;</title>
<link
rel="stylesheet"
href="default_style.css">
</head>
<body
link="#0000ff"
vlink="#800080">
<div align="right">&nbsp;
<table
border="0"
cellpadding="2"
cellspacing="0"
width="100%">
<tbody>
<tr>
<td
colspan="2"
align="left"
bgcolor="#0080c0"
valign="top"><b><font face="Arial,Helvetica"><font color="#ffffff">&nbsp;Eclipse
Corner Article</font></font></b></td>
</tr>
</tbody>
</table>
</div>
<div align="left">
<h1><img
src="images/Idea.jpg"
align="middle"
height="86"
width="120"
alt=""></h1>
</div>
<p></p>
<h1 align="center">WTP Tutorials - Deploy Web Applications to the Oracle Application Server</h1>
<blockquote><b>Summary</b> <br>
This tutorial will step you through the details of deploying a Web Application to the Oracle Application Server
Containers for J2EE (OC4J).
<p><b> By Raghu Srinivasan, Oracle Corporation.</b> <br>
<font size="-1">October 27, 2005</font></p>
</blockquote>
<hr width="100%">
<h3>Introduction</h3>
<p>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.</p>
<h3>Getting Started</h3>
<p>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:</p>
<ul>
<li>Java 2 Platform, Standard Edition(J2SE) 1.4</li>
<li>Eclipse and WTP</li>
<li>Oracle Application Server Containers for J2EE (OC4J</li>
</ul>
<h4>Java 2 Platform, Standard Edition(J2SE) 1.4</h4>
<p>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 <a href="http://java.sun.com/j2se/1.4.2/download.html">Sun's web site.</a>. Install the JDK.</p>
<p><img
src="images/note.gif"
height="13"
width="62"
alt=""> Make a note of the folder in which you install J2SE. This will be required later in the tutorial.</p>
<h4>Eclipse and WTP</h4>
<p>You need to download and install the <a
href="http://download.eclipse.org/webtools/downloads/drops/R-1.0-200512210855/">WTP 1.0 release build.</a> Download
the WTP all-in-one package. It includes the complete set of software to start using wtp immediately.</p>
<h4>Oracle Application Server Containers for J2EE (OC4J)</h4>
<p>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.</p>
<p>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 <a
href="http://www.oracle.com/technology/software/products/ias/index.html">Oracle download site</a>.</p>
<h5>Extract OC4J</h5>
<p>Extract the oc4j_extended_101300.zip file using any archive utility which handles zip files, including the jar
utility in the J2SE.</p>
<h5>Initialize OC4J</h5>
<p>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:</p>
<ul>
<li><b>JAVA_HOME</b>: Directory where J2SE was installed</li>
<li><b>ORACLE_HOME</b>: Directory where oc4j_extended_101300.zip was extracted.</li>
</ul>
For example, if J2SE was installed in
<b>C:\j2sdk1.4.2_09</b>
and oc4j_extended.zip was extracted to
<b>C:\Oracle\oc4j</b>
the environment variables should be set as follows:
<ul>
<li>JAVA_HOME=C:\j2sdk1.4.2_09</li>
<li>ORACLE_HOME=C:\Oracle\oc4j</li>
</ul>
Start the server.From the bin directory of oc4j, issue the following command:
<ul>
<li>oc4j -start</li>
</ul>
You should see the following messages in the console. You will be prompted to enter the password for the OC4J
administrator account.
<p><img
src="images/note.gif"
height="13"
width="62"
alt=""> Make a note of the password.</p>
<blockquote>
<ul>
<li>Starting OC4J from C:\Oracle\oc4j\j2ee\home ...</li>
<li>05/10/20 14:09:58 Set OC4J administrator's password (password text will not be displayed as it is entered)
</li>
<li></li>
<li>Enter password:</li>
<li>Confirm password:</li>
<li>Confirm password: The password for OC4J administrator "oc4jadmin" has been set.</li>
<li>05/10/20 14:10:41 The OC4J administrator "oc4jadmin" account is activated.</li>
<li>05/10/20 14:10:51 Oracle Containers for J2EE 10g (10.1.3.0.0) -Developer Preview 4 initialized</li>
</ul>
</blockquote>
Stop the server.From the bin directory of oc4j, issue the following command:
<ul>
<li>oc4j -shutdown -port 23791 -password <i>admin password</i></li>
</ul>
This completes the installation and configuration of all the required software.
<p><img
src="images/note.gif"
height="13"
width="62"
alt=""> The following information will be required in the later part of this tutorial</p>
<ul>
<li>User name of the OC4J administrator account is <b>oc4jadmin</b>.</li>
<li>The password for the administrator account.</li>
</ul>
<h3>Run a Web Application on the Oracle Application Server</h3>
<p>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:</p>
<ul>
<li>Create a server</li>
<li>Build a JSP Web Application</li>
<li>Deploy and Run the Web Application</li>
</ul>
<h4>Create a Server</h4>
<p>Launch Eclipse.<br>
Open the J2EE perspective; select <b>Window &gt; Open Perspective &gt; Other</b> 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.<br>
You will also need the Console view to see the output of the Server. Select <b>Window &gt; Show View &gt; Console</b>
menu.</p>
<p><img
src="images/tip.gif"
height="13"
width="62"
alt=""> From a command prompt, you can launch Eclipse using the following command:<br>
<i>$EclipseInstallFolder\eclipse\eclipse.exe -vm "$J2SEInstallFolder\bin\javaw.exe" -clean -data "$WorkspaceFolder"</i><br>
where <i>$EclipseInstallFolder</i> is folder where you installed Eclipse and <i>$WorkspaceFolder</i> is where you want
to create new or access an existing Eclipse workspace.</p>
<p>Figure 1 shows the Eclipse Workbench displaying the J2EE perspective. Note the Servers view and the Console view.</p>
<p><a name="figure1"><b>Figure 1. The Eclipse Workbench with the Servers view and the Console view.</b></a><br>
<img
alt="The Eclipse Workbench"
src="images/eclipse-j2ee.png"
height="552"
width="662"></p>
<p>Register the JDK you installed with Eclipse.<br>
</p>
<ul>
<li>Open <b>Windows&gt;Preferences</b>.</li>
<li>Select <b>Java&gt;Installed Runtimes</b>.</li>
<li>Select the Add button and in the resulting dialog, add the JDK you installed above.</li>
</ul>
<img
src="images/note.gif"
height="13"
width="62"
alt="">
For the field
<b>JRE home directory</b>
, point it to the root folder of the J2SE install and not the
<b>jre</b>
sub-folder.
<p>Next you register the Oracle Application Server runtime and create a server.<br>
Right-click in the Servers View and select <b>New &gt; Server</b> menu. This launches the New Server wizard.</p>
<p>Figure 2 shows the New Server Wizard with the Generic Oracle OC4J Standalone 10.1.3 DP4 Runtime selected.</p>
<p><a name="figure2"><b>Figure 2. The New Server Wizard</b></a><br>
<img
alt="The New Server Wizard"
src="images/new-server-oracle.png"
height="538"
width="530"></p>
<ol>
<li>In the <b>Define a New Server</b> panel, Select <b>Oracle &gt; Generic Oracle OC4J Standalone Server
10.1.3 DP4.</b> Click Next.</li>
<li>In the <b>Define a new Generic Oracle OC4J Standalone 10.1.3 DP4 Runtime</b> panel,
<ul>
<li>For JRE, select the JDK you registered above.</li>
<li>For Oracle J2EE Home, browse to the subdirectory <b>j2ee\home</b> in the folder where you installed the
Oracle Application Server. Click Next.</li>
</ul>
<p>Figure 3 shows the panel to register the Generic Oracle OC4J Standalone 10.1.3 DP4 Runtime.</p>
<p><a name="figure3"><b>Figure 3. Register the Generic Oracle OC4J Standalone 10.1.3 DP4 Runtime</b></a><br>
<img
alt="Register runtime"
src="images/new-server-oc4j.png"
height="538"
width="530"></p>
</li>
<li>In the <b>Create a new Generic Oracle OC4J Standalone 10.1.3 DP4 server</b> panel,
<ul>
<li>Set the password to the password for the administrator account you created during the Oracle
Application Server install.</li>
<li>Accept the defaults for all the other fields. Click Finish.</li>
</ul>
</li>
</ol>
You will see the Oracle OC4J Standalone 10.1.3 DP4 Preview server in the Servers view. Right-click on the server and
select
<b>Start</b>
to start the server. This starts the server and displays the output in the Console view.
<p>Figure 4 shows the Oracle OC4J Standalone 10.1.3 DP4 Preview server in the Servers view.</p>
<a name="figure4"><b>Figure 4. Oracle OC4J Standalone 10.1.3 DP4 Preview server in the Servers view</b></a>
<br>
<img
alt="Oracle OC4J Standalone 10.1.3 DP4 Preview server"
src="images/oc4j-server.png"
height="224"
width="619">
<h4>Build a JSP Web Application</h4>
<p>You will now build a simple JSP application that you will then run on the server. The <a
href="http://www.eclipse.org/webtools/index.html">Eclipse WTP</a> web site has a several tutorials that can help you
build sophisticated applications using the WTP tools.</p>
<p>The first step to build a JSP application is to create a Dynamic Web Project.</p>
<ul>
<li>From the ProjectExplorer view, right-click on the Dynamic Web Projects folder and select <b>New Dynamic
Web Project</b> menu.</li>
<li>Enter a name for the project, say, DemoOC4J.</li>
<li>Click on the button, ShowAdvanced.</li>
<li>Note that the Target runtime field is pre-populated with the entry for OC4J: Generic Oracle OC4J Standalone
10.1.3 DP4.</li>
<li>Accept the default values for all the fields in this dialog. Click Finish.</li>
</ul>
This will create the project.
<p></p>
<p>Next, you will create a JSP page.</p>
<ul>
<li>Open the Dynamic Web projects folder. Expand the project you created to the WebContent folder.</li>
<li>Right-click on the WebContent folder and select <b>New JSP</b> menu.</li>
<li>Enter a name for the file, say, index.jsp. Click Finish.</li>
<li>The file is opened in a JSP Editor. Enter the text between the <i>body</i> tags:</li>
<li><pre> &lt;% out.print("Hello World!!"); %&gt;</pre></li>
<li>Save the file.</li>
</ul>
You are ready to run the page on the server.
<p></p>
<h4>Deploy and Run the Web Application</h4>
<p>Right-click on the jsp file, index.jsp, in the ProjectExplorer. Select <b>Run As &gt; Run on Server</b> menu. <br>
In the Run On Server dialog, ensure that the server, <b>Oracle OC4J Standalone Server v10.1.3 DP4 Preview</b>, is
selected. Click on Finish. <br>
The Eclipse WTP tool will now do the following:</p>
<ul>
<li>Package the Web Application</li>
<li>Start the server if it is not running</li>
<li>Publish the Web Application to the Server</li>
<li>Launch the application in a browser</li>
</ul>
The Console view displays the log tracking the progress of the deployment.
<p>Figure 5 shows the application running on Oracle OC4J Standalone 10.1.3 DP4 Preview server.</p>
<a name="figure5"><b>Figure 5. Running the application on Oracle OC4J Standalone 10.1.3 DP4 Preview server.</b></a>
<br>
<img
alt="Running the application"
src="images/run-application-server.png"
height="545"
width="646">
<p></p>
<h3>Conclusion</h3>
<p>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.</p>
<h3>References</h3>
<p></p>
<ol>
<li><a href="http://www.eclipse.org/webtools/community/communityresources.html#articles">WTP Articles and
Tutorial.</a></li>
<li><a href="http://www.oracle.com/technology/products/ias/index.html">Oracle Application Server.</a></li>
</ol>
</body>
</html>