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.

“A build of the JavaService V2.0.7 software has now been provided by an external contributor for use on Windows systems running on AMD/Intel 64-bit. This has been used to run both Tomcat and JBoss successfully. Unfortunately, X64 builds cannot be provided for all future releases, but will be added on an occasional basis.”

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

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.

  • Bookmark "OC4J - Creation of a Windows Service with Javaservice" at del.icio.us
  • Bookmark "OC4J - Creation of a Windows Service with Javaservice" at Digg
  • Bookmark "OC4J - Creation of a Windows Service with Javaservice" at Ask
  • Bookmark "OC4J - Creation of a Windows Service with Javaservice" at Google
  • Bookmark "OC4J - Creation of a Windows Service with Javaservice" at StumbleUpon
  • Bookmark "OC4J - Creation of a Windows Service with Javaservice" at Technorati
  • Bookmark "OC4J - Creation of a Windows Service with Javaservice" at Live Bookmarks
  • Bookmark "OC4J - Creation of a Windows Service with Javaservice" at Yahoo! Myweb
  • Bookmark "OC4J - Creation of a Windows Service with Javaservice" at Facebook
  • Bookmark "OC4J - Creation of a Windows Service with Javaservice" at Yahoo! Bookmarks
  • Bookmark "OC4J - Creation of a Windows Service with Javaservice" at Twitter
  • Bookmark "OC4J - Creation of a Windows Service with Javaservice" at myAOL
 
web_server/oc4j/oc4j_service.txt · Last modified: 2010/02/26 11:49 by gerardnico