Search & Win   click me  


  


Using OC4J outside of JDeveloper

by Jeff Hunter, Sr. Database Administrator


Contents

  1. Introduction
  2. Setting up OC4J - (JDeveloper 9i)
  3. Setting up OC4J - (JDeveloper 10g)



Introduction

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 - (JDeveloper 9i)

This section 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.

  1. 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.

  2. Change to the directory of your JDeveloper base installation:
    cd %JDEV_HOME%

  3. 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

  4. 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
    

  5. Start the OC4J Server:
    start java -jar oc4j.jar
    This 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.

  6. Now, start a browser and navigate to the OC4J server:
    http://localhost:8888
    You 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.

  7. 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> -shutdown
    In 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.



Setting up OC4J - (JDeveloper 10g)

This section 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.

  1. 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.

  2. Change to the JDeveloper bin directory:
    cd %JDEV_HOME%\jdev\bin

  3. Run the OC4J startup script. If this is the first time running the OC4J startup script, any uninstalled applications are unpacked plus the installation (setup) program is run which will ask for the password to use for the oc4jadmin user:
    start_oc4j
    Starting OC4J with command: "C:\Java\jdk1.5.0_07\bin\java.exe"  -jar oc4j.jar
    2007-03-01 11:45:15.337 NOTIFICATION Auto-unpacking C:\JDeveloper\j2ee\home\applications\dms.war...
    2007-03-01 11:45:15.347 NOTIFICATION Unjar C:\JDeveloper\j2ee\home\applications\dms.war in C:\JDeveloper\j2ee\home\applications\dms
    2007-03-01 11:45:15.357 NOTIFICATION Finished auto-unpacking C:\JDeveloper\j2ee\home\applications\dms.war
    2007-03-01 11:45:15.357 NOTIFICATION Auto-unpacking C:\JDeveloper\j2ee\home\applications\JMXSoapAdapter-web.war...
    2007-03-01 11:45:15.367 NOTIFICATION Unjar C:\JDeveloper\j2ee\home\applications\JMXSoapAdapter-web.war in C:\JDeveloper\j2ee\home\applications\JMXSoapAdapter-web
    2007-03-01 11:45:15.458 NOTIFICATION Finished auto-unpacking C:\JDeveloper\j2ee\home\applications\JMXSoapAdapter-web.war
    2007-03-01 11:45:15.768 NOTIFICATION Auto-unpacking C:\JDeveloper\j2ee\home\applications\jmsrouter.war...
    2007-03-01 11:45:15.768 NOTIFICATION Unjar C:\JDeveloper\j2ee\home\applications\jmsrouter.war in C:\JDeveloper\j2ee\home\applications\jmsrouter
    2007-03-01 11:45:15.808 NOTIFICATION Finished auto-unpacking C:\JDeveloper\j2ee\home\applications\jmsrouter.war
    2007-03-01 11:45:15.858 NOTIFICATION Auto-unpacking C:\JDeveloper\j2ee\home\connectors\datasources\datasources.rar...
    2007-03-01 11:45:15.858 NOTIFICATION Unjar C:\JDeveloper\j2ee\home\connectors\datasources\datasources.rar in C:\JDeveloper\j2ee\home\connectors\datasources\datasources
    2007-03-01 11:45:15.898 NOTIFICATION Finished auto-unpacking C:\JDeveloper\j2ee\home\connectors\datasources\datasources.rar
    2007-03-01 11:45:15.898 NOTIFICATION Auto-unpacking C:\JDeveloper\j2ee\home\connectors\OracleASjms\OracleASjms.rar...
    2007-03-01 11:45:15.898 NOTIFICATION Unjar C:\JDeveloper\j2ee\home\connectors\OracleASjms\OracleASjms.rar in C:\JDeveloper\j2ee\home\connectors\OracleASjms\OracleASjms
    2007-03-01 11:45:16.008 NOTIFICATION Finished auto-unpacking C:\JDeveloper\j2ee\home\connectors\OracleASjms\OracleASjms.rar
    2007-03-01 11:45:16.118 NOTIFICATION Auto-unpacking C:\JDeveloper\j2ee\home\applications\ascontrol.ear...
    2007-03-01 11:45:16.118 NOTIFICATION Unjar C:\JDeveloper\j2ee\home\applications\ascontrol.ear in C:\JDeveloper\j2ee\home\applications\ascontrol
    2007-03-01 11:45:18.882 NOTIFICATION Finished auto-unpacking C:\JDeveloper\j2ee\home\applications\ascontrol.ear
    2007-03-01 11:45:18.902 NOTIFICATION Auto-unpacking C:\JDeveloper\j2ee\home\applications\ascontrol\ascontrol.war...
    2007-03-01 11:45:18.902 NOTIFICATION Unjar C:\JDeveloper\j2ee\home\applications\ascontrol\ascontrol.war in C:\JDeveloper\j2ee\home\applications\ascontrol\ascontrol
    2007-03-01 11:45:28.246 NOTIFICATION Finished auto-unpacking C:\JDeveloper\j2ee\home\applications\ascontrol\ascontrol.war
    2007-03-01 11:45:28.256 NOTIFICATION Auto-unpacking C:\JDeveloper\BC4J\redist\bc4j.ear...
    2007-03-01 11:45:28.256 NOTIFICATION Unjar C:\JDeveloper\BC4J\redist\bc4j.ear in C:\JDeveloper\BC4J\redist\bc4j
    2007-03-01 11:45:30.109 NOTIFICATION Finished auto-unpacking C:\JDeveloper\BC4J\redist\bc4j.ear
    2007-03-01 11:45:30.109 NOTIFICATION Auto-unpacking C:\JDeveloper\BC4J\redist\bc4j\webapp.war...
    2007-03-01 11:45:30.109 NOTIFICATION Unjar C:\JDeveloper\BC4J\redist\bc4j\webapp.war in C:\JDeveloper\BC4J\redist\bc4j\webapp
    2007-03-01 11:45:35.707 NOTIFICATION Finished auto-unpacking C:\JDeveloper\BC4J\redist\bc4j\webapp.war
    07/03/01 11:45:36 Set OC4J administrator's password (password text will not be displayed as it is entered)
    Enter password: manager
    Confirm password: manager
    The password for OC4J administrator "oc4jadmin" has been set.
    07/03/01 11:45:44 The OC4J administrator "oc4jadmin" account is activated.
    2007-03-01 11:46:01.144 NOTIFICATION JMS Router is initiating ...
    07/03/01 11:46:03 Oracle Containers for J2EE 10g (10.1.3.0.0)  initialized

  4. Now, start a browser and navigate to the OC4J server:
    http://localhost:8888
    You 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.

  5. 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 oc4jadmin <oc4jadmin_password> -shutdown
    In the above command line, <oc4jadmin_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.



Last modified on: Saturday, 18-Sep-2010 18:02:36 EDT
Page Count: [an error occurred while processing this directive]