DBA Tips Archive for Oracle
Using OC4J in JDeveloper9i
by Jeff Hunter, Sr. Database Administrator
JDeveloper includes a version of OC4J that can run standalone or from within the JDeveloper IDE. This comes in handy when you need to test applications and deployment while using JDeveloper. (i.e. JSPs, Servlets, EJBs). Whenever you attempt to run a JSP, Servlet or any application that uses an EJB, the JDeveloper IDE will startup the OC4J Server (often called the embedded OC4J Server) and allows you to run the application without ever having to leave the JDeveloper IDE environment. Alternatively, you can run these applications outside of JDeveloper using an OC4J Server (or other J2EE Server). This methods allows the application developer to access and run applications from outside of JDeveloper.
It is important to understand that these steps are not necessary when developing and debugging applications since JDeveloper includes an embedded version that gets invoked when you attempt to run an application that requires it. This version of the OC4J server allows you to test your application (JSPs, Servlets, EJBs) in an OC4J environment without leaving the JDeveloper environment. There are times, however, where you may want to emulate deployment to another server. This article documents the steps necessary to setup and use the embedded OC4J Server to allow it to run outside of JDeveloper.
Setting up OC4J
This article uses the environment variable JDEV_HOME to indicate the base directory of your JDeveloper installation. In the case of my machine, the JDEV_HOME environment variable is pointing to C:\JDeveloper.
- First, bring up an MS-DOS command prompt. (From the Start menu, select Run from the Windows start menu and enter cmd in the Open field and click OK.
- Change to the directory of your JDeveloper base installation:cd %JDEV_HOME%
- Enter the following on the command line in order to set the environment variables to point to the JDeveloper installation of Java:jdev\bin\setvars -go
- Change to the following directory and run the installation (setup) script:cd j2ee\home java -jar oc4j.jar -install Auto-unpacking C:\JDeveloper\j2ee\home\applications\dms0.war... done. Auto-unpacking C:\JDeveloper\j2ee\home\applications\dms.war... done. Auto-unpacking C:\JDeveloper\BC4J\redist\bc4j.ear... done. Auto-unpacking C:\JDeveloper\BC4J\redist\bc4j\webapp.war... done. Auto-unpacking C:\JDeveloper\BC4J\redist\bc4j\cabo.war... done. Auto-deploying bc4j (New server version detected)... Auto-unpacking C:\JDeveloper\soap\webapps\soap.ear... done. Auto-unpacking C:\JDeveloper\soap\webapps\soap\soap.war... done. Auto-deploying soap (New server version detected)... Enter an admin password to use: manager Confirm admin password: manager Installation done
- Start the OC4J Server:start java -jar oc4j.jarThis command will open another command line window (by using the Windows start command) and starts the OC4J Server. You will see a message indicating that the server is initialized, but no command line prompt will appear in this windows. You will need to leave this command line window open.
- Now, start a browser and navigate to the OC4J server:http://localhost:8888You should be directed to the default home page for the OC4J Server. It is a file called index.html in the JDEV_HOME\j2ee\home\default-web-app directory. The index file contains several links to sample pages for testing JSP and Servlet applications. All samples were developed by Sun Microsystems. There are links that also allow you to view the source code for all applications. You will also find links to the OC4J documentation. Keep in mind that all of these files are located in the JDEV_HOME\j2ee directory.
- When you are ready to shutdown the OC4J Server, enter the following at a command line prompt:cd %JDEV_HOME%\j2ee\home java -jar admin.jar ormi://localhost admin <admin_password> -shutdownIn the above command line, <admin_password> represents the password you entered when setting up the OC4J server (above). The command line window that showed the OC4J Server initialization will be automatically closed.
If the window does not close, switch to the OC4J initialization windows, and press CTL-C to stop the process and terminate the session.
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.