OC4J as a Windows Service

Some Oracle Application like BI Publisher 10g uses OC4J, which is an Oracle Application Server which enables J2EE applications to run. These set of containers, API and services have to be started manually at system start up and after system downtime. It is annoying for system administrators to have manual task to take care of. So, if we are in a Windows environment, these tasks can be avoided if they are defined as an automatic start-up process within the MS Windows Service. Installing OC4J as a MS Windows Services we will solve that inconvenience we will take a step further in automation wise and we will decrease the services downtimes. Listed below are the steps for implementing this solution:

1. Use of a free utility call JavaService to install OC4J as a service that can be downloaded from : http://forge.ow2.org/projects/javaservice/

2. Copy the JavaService.exe executable to the directory {OracleBI_HOME}\oc4j_bi\bin can be modified as desired, I named it to OC4JService.exe

3. Create a batch file with the appropriate command lines to perform the expected behaviour A set of commands available from JavaService are:

– Version Outputs the built-in version number of the JavaService program
– License (or -licence) Outputs the LGPL licensing text covering the program
– Install servicename Installs the named service with specified configuration options
– Queryconfig servicename (or -query) Displays confguration details for the installed Java service
– Status servicename Displays current execution status of the named Java service
– Uninstall servicename Removes definition of the specified Java service ** Detailed information about JavaService installation parameters in the official webpage: http://javaservice.ow2.org/docs/devdocs/devcmds.html

The default configuration of the running OC4J will serve as a baseline for creating the command lines.

E:\JavaService\OC4JService.exe -install Oracle_BI_OC4J  “C:\Java\jdk1.6.0_21\jre\bin\client\jvm.dll” -XX:+AggressiveHeap “-Djava.class.path={OracleBI_HOME}\oc4j_bi\j2ee\home\oc4j.jar” -start oracle.oc4j.loader.boot.BootStrap -params -out “{OracleBI_HOME}\oc4j_bi\j2ee\home\log\oc4j.log.txt” -err “{OracleBI_HOME}\oc4j_bi\j2ee\home\log\oc4.err.txt” -current “{OracleBI_HOME}\oc4j_bi\bin” -description “Oracle BI Application”

Command details below:

Oracle_BI_OC4J: The service name
– “C:\Java\jdk1.6.0_21\jre\bin\client\jvm.dll”:
Location of the jre to use -XX:+AggressiveHeap:

Command to define better config based on features

 

 

–  “-Djava.class.path={OracleBI_HOME}\oc4j_bi\j2ee\home\oc4j.jar” Location of the oc4j.jar, the main jar for OC4J
–  start oracle.oc4j.loader.boot.BootStrap: Class to start from that jar, leave this as – The parameters after -params are optional and are just an output log, an error log and a description for the service

4. Execute the batch file to create the Service

5. Go to windows àRun à type and execute “Services.msc”

6. and start Oracle_BI_OC4J It is likely that you won’t get the expected result at once, so I would like to share a statement to delete the service created in case of getting mistaken and starting over:

E:\JavaService\OC4JService.exe -uninstall Oracle_BI_OC4J

Summarising, creating this Windows Service we benefit of higher system availability what means lower application downtimes, therefore it will make our sponsor, users and system administrators happier.

Sergi G
sergi.guinon@clearpeaks.com