Thursday, January 24, 2008

Installing OIM as a Windows Service

On Production, if you want Xellerate to run as a Windows Service so that it can be restarted automatically on a server restart, you can do the following things.

1. Get JavaService.exe from the web (open source project) and deploy it in your JBOSS\bin directory.
2. Use the following script to install this as a web serivce. The following script will need some tweaking of parameters depending on your environment:
================================================
Here is the script
================================================

@echo off
setlocal

rem
rem -------------------------------------------------------
rem This script sets the JBoss instance for OIM to run
rem as a windows service. You may need to tweak the
rem variables below to properly define your installation.
rem
rem
rem
rem -------------------------------------------------------
rem

rem This sets the memory usage settings passed to the JVM
set MEM_ARGS=-Xmx1024m

rem This is the directory where OIM is installed in
set XL_HOME=C:\xellerate\xlserver\xellerate

rem This is the directory where JBoss is installed in
set JB_HOME=C:\xellerate\jboss-4.0.3SP1

rem This is the base directory of the JDK installation for JBOSS
set JAVA_HOME=C:\java\j2sdk1.4.2_13\jre

rem This is the name of the Windows service
set SERVICE_NAME=JBoss-OIM

rem
rem -------------------------------------------------------
rem End of common variables you may need to tweak
rem -------------------------------------------------------
rem

echo Attempting to stop and remove old OIM / JBoss service
net stop %SERVICE_NAME% /y
javaservice.exe -uninstall %SERVICE_NAME%
echo Done.

echo Attempting to install and start OIM / JBoss service
mkdir %JB_HOME%\logs
copy /f javaservice.exe %JB_HOME%\bin
cd %JB_HOME%\bin
javaservice.exe -install %SERVICE_NAME% %JAVA_HOME%\bin\client\jvm.dll %MEM_ARGS% -Djava.class.path="%JAVA_HOME%\lib\tools.jar;%JB_HOME%\bin\run.jar" -DXL.HomeDir=%XL_HOME% -Djava.awt.headless=true -start org.jboss.Main -stop org.jboss.Main -method systemExit -out %JB_HOME%\logs\console.log -err %JB_HOME%\logs\console.log -current %JB_HOME%\bin -path "%PATH%" -auto

net start %SERVICE_NAME%
echo Done.
endlocal



================================================
Here is how it will get installed.
================================================


================================================
Here is how it looks after getting installed as a Windows Service.
================================================


Notes:
================================================
1. Also copy javaservice.exe & jvm.dll to C:\<WindowsInstallFolder>\system32 (say C:\Windows\system32) as after restart if these files are not in path, the windows service will fail to start.

2 comments:

Phaedrus said...

Thanks!! this is great. Do you know if this solution is Oracle supported?

Rajnish Bhatia said...

I do not believe so. This is a usage based developed solution.