How to install OC4J server on Linux Centos

OC4J or Oracle Containers for J2EE is a complete J2EE compliant environment that provides all the containers, APIs, and services that enable a J2EE product to run. It is actually a robust and minimal distribution of Oracle Application Server, developed entirely in Java. More about OC4J you can read here: What is OC4J? One particular use for this web server is APEX print server. APEX usually allows only two possible configurations for the report printing server: standard (we will use OC4J) and advanced which requires Oracle BI. And Oracle BI costs "just" a few thousand dollars so… OC4J it is!

Prerequisites. Install Java2SE

We will demonstrate installing OC4J on a Linux Centos 5 machine.

Before installing OC4J you need to install at least Java2SE JDK version 1.3.1 or later. At the time this article was published, Oracle released the J2SE 1.6 version. If you already have Java installed on your machine, skip this part. Else, install Java2SE:

If not, download the appropriate J2SE for your platform (in our case, Linux 64 bit) from http://www.oracle.com/technetwork/java/javase/downloads/index.html

Copy the .bin file to your Linux server, log in as root (or su as root), change the directory to the location of the java bin file. The file name should be like  <version>-linux-x64-rpm.bin.

As root, execute from the command line:

chmod a+x jdk-6u

./jdk-6u<version>linux-x64-rpm.bin

Java2SE will install on your machine

Install OC4J

Download OC4J installation kit from from http://download.oracle.com/otn/java/oc4j/903/oc4j_extended.zip.

Copy the zip file on your Linux machine and unzip it to a desired folder. Out choice was /usr/lib/oracle/OC4J. After the archive was unziped change the folder to j2ee/home. We will further call /usr/lib/oracle/OC4J/j2ee/home the OC4J_home. Older versions required a build and configuration of OC4J by running java -jar oc4j.jar -install. This is deprecated at the moment and simply run 

java -jar oc4j.jar

or

java -jar oc4j.jar &

to start OC4J in background.

You will be prompted will an administrator password the first time your start OC4J.

The output should look like this:

2011-02-16 04:00:39.253 NOTIFICATION Auto-unpacking /usr/lib/oracle/OC4J/j2ee/home/applications/dms.war…
2011-02-16 04:00:39.259 NOTIFICATION Unjar /usr/lib/oracle/OC4J/j2ee/home/applications/dms.war in /usr/lib/oracle/OC4J/j2ee/home/applications/dms
2011-02-16 04:00:39.280 NOTIFICATION Finished auto-unpacking /usr/lib/oracle/OC4J/j2ee/home/applications/dms.war
2011-02-16 04:00:39.282 NOTIFICATION Auto-unpacking /usr/lib/oracle/OC4J/j2ee/home/applications/JMXSoapAdapter-web.war…
[…]
11/02/16 04:00:43 Set OC4J administrator's password (password text will not be d                                                                             isplayed as it is entered)
Enter password:
Confirm password:
The password for OC4J administrator "oc4jadmin" has been set.
11/02/16 04:00:55 The OC4J administrator "oc4jadmin" account is activated.
11/02/16 04:01:05 Oracle Containers for J2EE 10g (10.1.3.5.0)  initialized

The final message means that OC4J is up and running. Test this by accessing in the web browser the address: http://mydomain:8888 . The welcome page from Oracle Application Server should appear if successful:

apexninjas.com oracle application server oc4j

 

Start OC4J as a service

The recommended way to start the OC4J server is as a service or daemon. For this, use the script available here. Just configure the variables at the beginning of the script like this:

# Set this to your Java installation
JAVA_HOME=/usr/java/default

serviceNameLo="oc4j"                                  
serviceName="oc4j"                                   
serviceUser="root"                                      
serviceGroup="root"                                   
applDir="/var/lib/oracle/OC4J/j2ee/home"                        
serviceUserHome="/root"                      
serviceLogFile="/var/log/$serviceNameLo.log"               
maxShutdownTime=15                                        
pidFile="/var/run/$serviceNameLo.pid"                      
javaCommand="java"                                         
javaExe="$JAVA_HOME/bin/$javaCommand"                      
javaArgs="-jar $applDir/oc4j.jar"                     
javaCommandLine="$javaExe $javaArgs"                      
javaCommandLineKeyword="oc4j.jar"                    


 

Leave a Reply