Oracle DBA Tips Corner |
|
Deploying Applications
by Jeff Hunter, Sr. Database Administrator
Introduction
You can deploy a J2EE Web application to the OC4J Web server using either the-deployoption with theadmin.jarcommand line tool or by manually adding the appropriate elements to the OC4J XML configuration files. The following document explains how to deploy an application to the OC4J server using both methods.For the purpose of this document, I will provide all examples using a fictitious application called
my_app.Before performing the actual "deployment" steps to OC4J, you will need to perform the following actions:
- DataSource - (optional) If your application will be require access to an external data source (i.e. a relational database) you will need to configure the
data-sources.xmlfile by adding the appropriate<data-source ... />element. For example:<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="scott" password="tiger" url="jdbc:oracle:thin:@<database_server>:<database_port>:<oracle_sid>" inactivity-timeout="30" />
- Next, copy the Enterprise Application Archive file (*.ear file) to the
$OC4J_HOME/j2ee/home/applicationsdirectory.% cp my_app.ear $OC4J_HOME/j2ee/home/applications
Deploying Application Using admin.jar -deploy
You can make use of theadmin.jarcommand-line utility to deploy the my_app application. The following two commands can be used to deploy the J2EE application as well as the Web application. Using this method allows for remote deployment.
- Register the J2EE application (generally the EJBs / business logic):
% java -jar admin.jar ormi://<oc4j_host>:<oc4j_ormi_port> admin manager -deploy -file $OC4J_HOME/j2ee/home/applications/my_app.ear -deploymentName my_app -targetPath applications/This step creates the entry in the
server.xmlfile for the my_app application.
- To bind the Web application through the
admin.jartool, use the following:% java -jar admin.jar ormi://<oc4j_host>:<oc4j_ormi_port> admin manager -bindWebApp my_app my_app-web http-web-site /my_appThis creates the
<web-app>entry element in thehttp-web-site.xmlconfiguration file.
- If the OC4J server is not running, use the following to start the OC4J instance:
% cd $OC4J_HOME/j2ee/home % java -jar oc4j.jar -verbosity 10
- The application should now be accessible from the following URL:
http://<oc4j_host>:8888/my_app
Deploying Application by Manually Adding XML Elements
In order to register the my_app applciation, you will need to add the J2EE application in theserver.xmlfile and its Web application in thehttp-web-site.xmlfile.
- In the
$OC4J_HOME/j2ee/home/config/server.xmlfile, add the my_app entry, as follows:<application name="my_app" path="../applications/my_app.ear" auto-start="true" />
- In the
$OC4J_HOME/j2ee/home/config/http-web-site.xmlfile, bind the my_app application by adding the web-app entry, as follows:<web-app application="my_app" name="my_app-web" root="/my_app" load-on-startup="true" />This step will make the application accessible from the OC4J server.
- If the OC4J server is not running, use the following to start the OC4J instance:
% cd $OC4J_HOME/j2ee/home % java -jar oc4j.jar -verbosity 10
- The application should now be accessible from the following URL:
http://<oc4j_host>:8888/my_app
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 jhunter@idevelopment.info.
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.