DBA Tips Archive for Oracle
Deploying WAR Files to OC4J
by Jeff Hunter, Sr. Database Administrator
The common-line tool admin.jar is used to deploy applications to the OC4J environmnet. Unfortunately the admin.jar utility requires an EAR file as its deployment archive. There is no option for deploying a WAR file directory. To deploy a WAR file using the admin.jar utility, you must package the WAR file within an EAR file and using a manual process.
This article describes the process of manually deploying a WAR file to the OC4J environment. For the purpose of this exercise, I will be deploying a war file named "ServletExamplesApp.war". It is a simple web application (archive) that contains two servlets and a single html file (index.html) used to access the servlets. The Web Context Root is named "ServletExamples".
You can download a copy of the the example WAR file from this location: "ServletExamplesApp.war".
Setting up OC4J
The following instructions will allow you to manually deploy a WAR file (ServletExamplesApp.war) to an OC4J instance. For this example, <OC4J_HOME> is the location where OC4J is installed.
- First, copy the WAR file to <OC4J_HOME>\j2ee\home\applications:copy ServletExamplesApp.war <OC4J_HOME>\j2ee\home\applications
- Open the application.xml file in the <OC4J_HOME>\j2ee\home\config directory and add the following after the entry "<web-module id="defaultWebApp" path="../../home/default-web-app" />" as follows:... <web-module id="defaultWebApp" path="../../home/default-web-app" /> <web-module id="ServletExamplesApp" path="../../home/applications/ServletExamplesApp.war" /> ...
- Open the file http-web-site.xml in the <OC4J_HOME>\j2ee\home\config directory and add the following after the entry "<default-web-app application="default" name="defaultWebApp" />" as follows:... <default-web-app application="default" name="defaultWebApp" /> <web-app application="default" name="ServletExamplesApp" root="/ServletExamples" /> ...
- You should now be able to navigate to the newly deployed web application using the following URL:
Copyright (c) 1998-2018 Jeffrey M. Hunter. All rights reserved.
All articles, scripts and material located at the Internet address of http://www.idevelopment.info is the copyright of Jeffrey M. Hunter and is protected under copyright laws of the United States. This document may not be hosted on any other site without my express, prior, written permission. Application to host any of the material elsewhere can be made by contacting me at email@example.com.
I have made every effort and taken great care in making sure that the material included on my web site is technically accurate, but I disclaim any and all responsibility for any loss, damage or destruction of data or any other property which may arise from relying on it. I will in no case be liable for any monetary damages arising from such loss, damage or destruction.