OC4J - Creation of a Windows Service with Javaservice
Introduction
On Windows, when the machine fails and/or is rebooted, OC4J for OBIEE is unavailable for remote commands until a user logs in and starts it. As an solution, you can configure the OC4J process :
- as a Windows service that will run automatically when the machine boots.
- as a scheduled task.
The most common method used is to install OC4J as service with JavaService.
And if you don't have already done this step, you must perform it before to continue :
Articles Related
Syntax and parameters of javaservice
JavaService (Windows NT Service Daemon) commands:-
-version
-licence
-install service_name jvm service_options...
-queryconfig service_name
-status service_name
-uninstall service_name
-help
-help topic
But you have more options that you can found on this page JavaService installation parameters.
You can redirect for instance the log file with this parameters:
- -out out_log_file (optional) - A file into which System.out will be redirected. If this parameter is not specified, System.out will not be redirected.
- -err err_log_file (optional) - A file into which System.err will be redirected. If this parameter is not specified, System.err will not be redirected.
Installation Steps
for 32 Bit machines
From Metalink, if you want to run oc4j as a windows service download the open source tool named JavaService.exe from http://javaservice.objectweb.org/ which can create Windows Services for Java Programs.
Download the version JavaService-2.0.10, adjust the path and execute the following command:
javaservice -install "Oracle BI: OC4J Service" "PathToJDK32Bit\jre\bin\client\jvm.dll" -XX:MaxPermSize=128m -Xmx512m "-Djava.class.path=OBI_HOME\oc4j_bi\j2ee\home\oc4j.jar" -start oracle.oc4j.loader.boot.BootStrap -out "OBI_HOME\oc4j_bi\j2ee\home\log\oc4j.log.txt" -err "OBI_HOME\oc4j_bi\j2ee\home\log\oc4j.err.txt" -description "Oracle BI Oc4J Service"
for 64 Bit machines
From Metalink, if you want to run oc4j as a windows service download the open source tool named JavaService.exe from http://javaservice.objectweb.org/ which can create Windows Services for Java Programs.
The Jdk must be in 64 bit.
Download the version JavaService-2.0.7.64, adjust the path and execute the following command:
javaservice -install "Oracle BI: OC4J Service" "C:\Program Files\Java\jdk1.6.0_06\jre\bin\server\jvm.dll" -XX:MaxPermSize=128m -Xmx512m "-Djava.class.path=OracleBI_home\oc4j_bi\j2ee\home\oc4j.jar" -start oracle.oc4j.loader.boot.BootStrap
Where are the parameters ? In the registry
Start the regedit which is in the directory C:\WINDOWS\SysWOW64 if you are in a 64 bit environement
HKLM\SYSTEM\CONTROLSET001\Services
Support
Unrecognised or incorrectly-ordered parameters for install command
If you receive this error during the installation, be careful with the order of the parameters. The description must be at the end of the command for instance.
Unrecognised or incorrectly-ordered parameters for install command The last 2 parameters (from '-description') were not recognised JavaService install command parameters not valid, or incomplete
LoadLibrary is not a valid Win32 application
If you receive this error during the start of the service (check the Application/Event Viewer)
The LoadLibrary function failed for the following reason: LoadLibrary is not a valid Win32 application.
It's because in 64 bit, you must use a 64 java version and not a 32 bit.
The specified module could not be found
If you receive this error during the start of the service (check the Application/Event Viewer)
The LoadLibrary function failed for the following reason: The specified module could not be found.
It's because the path that you have specified during the installation are not good. You deinstall the service with the uninstall.bat file or you can modify them in the registry.
Others possibilities
Windows Service with NT/Win2k Resource Kit
Answer from the Oracle OC4J FAQ, only for 32 Bit machines
How can I start OC4J standalone as a service in NT ?
In Oracle9iAS Release 2, OC4J is started as a managed process by Oracle Process Management Notification (OPMN). This provides automatic startup, shutdown and death detection functionalities for OC4J processes. For environments which require the use of OC4J as a service, Oracle9iAS should be used.
Optionally, you can set OC4J as a service in Windows as follows:
- Create a command file to start OC4J as follows:
set PATH=c:\java1.3\bin;%PATH cd \oracle\ias\j2ee\home java -jar oc4j.jar
- Create a service for the this command file using NT/Win2k Resource Kit. You can use the following Microsoft article how to create a service: http://support.microsoft.com/support/kb/articles/q137/8/90.asp
This solution is only good for 32bit machine because Windows do not support srvany.exe (in the ressource Toolkit on a Windows 2003 64-bit machines.
Scheduled task
Start OC4J at startup
Just configure OC4J to start when the system startup. Note that when starting OC$J as a scheduled task, it does not display any dialog.
Stop OC4J
You must stop the task with the command “Stop OC4J” in the menu or by issuing this command
java.exe" -jar OracleBI_Home\oc4j_bi\j2ee\home\admin.jar ormi://localhost:23791 oc4jadmin oc4jadminpassword -shutdown force
Otherwise, it's not possible to stop OC4J because we can't answer to the annoy “Terminate batch job (Y/N)?” answer in scheduled task mode.



