[OPENIDM-482] OpenIDM should be able to run as a windows service Created: 28/Nov/11  Updated: 20/Nov/16  Due: 09/Dec/11  Resolved: 20/Nov/16

Status: Closed
Project: OpenIDM
Component/s: Module - Command line
Affects Version/s: OpenIDM 2.0.0 EA, OpenIDM 3.1.0
Fix Version/s: OpenIDM 5.0.0

Type: Bug Priority: Major
Reporter: Gael Allioux Assignee: Mareks Malnacs
Resolution: Fixed Votes: 2
Labels: Expired
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows


Attachments: PNG File Screen shot 2013-08-20 at 10.21.26 AM.png     PNG File Screen shot 2013-08-20 at 10.22.09 AM.png     Text File eventlog.txt    
Issue Links:
Depends
is required by OPENIDM-2867 Installing OpenIDM as a Windows Service Closed
is required by OPENIDM-2511 Document how to install OpenIDM as a ... Closed
Target Version/s:
Cases: 2496
Support Ticket IDs:

 Description   

OpenIDM should be able to run as a windows service using a wrapper like
the Java Service Wrapper (http://wrapper.tanukisoftware.com/doc/english/download.jsp).

Otherwise, Felix console has to stay open and if user logs off, openidm is killed



 Comments   
Comment by Laszlo Hordos [ 28/Nov/11 ]

OpenICF has an executable service binary at https://svn.forgerock.org/openicf/trunk/framework/java/openicf-zip/src/main/resources/bin/ but we should use the same technology to makes these processes as a service.

Comment by Andi Egloff [ 24/Jan/12 ]

First a proper evaluation of the available tools and their licensing is required.

The linked tool for example is GPL licensed, which we can not re-distribute with OpenIDM.

I would specifically recommend that we include
http://yajsw.sourceforge.net/#mozTocId326435
in the evaluation before we decide and proceed with realizing this jira.

Comment by Laszlo Hordos [ 02/Jan/13 ]

The launcher.bat was updated and it can install/uninstall the OpenIDM service from script attached to CR-1155

Comment by Tinghua.Xu [ 20/Aug/13 ]

Tried to verify it but was not successful.
What I did:
1. Installed Apache daemons by following http://code.google.com/p/orient/wiki/WrappingAsAWindowsService
(Is it really needed? as the openidm bundle has all the command prunsrv.exe)

2. run openidm\bin\install-service.bat
what I saw,
ForgerockLauncherJavaService is installed as a service on windows but can't be started. Got an error when started it. See screenshot for details.

See the following in command window.

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>install-servic
e.bat

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>rem @echo off

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>set "EXECUTABL
E=C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin\launcher.bat
"

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>rem Check that
target executable exists

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>if exist "C:\U
sers\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin\launcher.bat" goto
execOK

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>rem Get remain
ing unshifted command line arguments and save them in the

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>set CMD_LINE_A
RGS=

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>if """" == """
" goto doneSetArgs

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>rem set SERVER
_START_PARAMS="-c;bin/launcher.json"

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>set CP=bin/lau
ncher.jar;bin/felix.jar

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>set JAVA_OPTS_
SERVICE=-Xmx1024m;-Djava.util.logging.config.file=conf\logging.properties;-Dlogb
ack.configurationFile=conf\logging-config.xml;

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>rem Enable deb
ugging uncomment the line below

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>set JAVA_OPTS_
SERVICE=-Xmx1024m;-Djava.util.logging.config.file=conf\logging.properties;-Dlogb
ack.configurationFile=conf\logging-config.xml;-agentlib:jdwp=transport=dt_socket
,server=y,suspend=n,address=5005;

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>call "C:\Users
\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin\launcher.bat" /install

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>rem @echo off

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>SETLOCAL ENABL
EDELAYEDEXPANSION

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>rem Set Launch
er Home

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>set CURRENT_DI
R=C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>cd /d "C:\User
s\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin\launcher.bat"\..

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>set SCRIPT_DIR
=C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>cd ..

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm>if not "" == "" go
to homeSet

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm>set LAUNCHER_SERVE
R_HOME=C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm>cd "C:\Users\Admin
istrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin""

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>if exist "C:\U
sers\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin\launcher.bat" goto
homeOk

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>rem Check Java
availability

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>if not "C:\Pro
gram Files (x86)\Java\jre7\" == "" goto checkJavaHome

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>if exist "C:\P
rogram Files (x86)\Java\jre7\\bin\java.exe" goto javaHomeOk

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>set JAVA="C:\P
rogram Files (x86)\Java\jre7\\bin\java.exe"

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>set JAVA_DLL="
C:\Program Files (x86)\Java\jre7\\jre\bin\server\jvm.dll"

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>rem Check and
Set CLASSPATH for starting Launcher

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>if not "bin/la
uncher.jar;bin/felix.jar" == "" goto classpathOK

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>rem SET MISC P
ROPERTIES

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>rem Architectu
re, can be i386 or amd64 or ia64 (it is basically the directory name

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>rem where the
binaries are stored, if not set this script will try to

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>rem find the v
alue automatically based on environment variables)

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>set ARCH=

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>rem find out t
he architecture

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>if """" == """
" (
set ARCH=i386
if ""AMD64"" == ""AMD64"" set ARCH=amd64
if ""AMD64"" == ""IA64"" set ARCH=ia64
)

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>rem ----------
---------------------------------------------------

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>rem Service ja
va options, needs to be separated by ;

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>if not "-Xmx10
24m;-Djava.util.logging.config.file=conf\logging.properties;-Dlogback.configurat
ionFile=conf\logging-config.xml;-agentlib:jdwp=transport=dt_socket,server=y,susp
end=n,address=5005;" == "" goto optsOK

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>rem Set Launch
er start params, needs to be separated by ;

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>if not "" == "
" goto launcerStartOK

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>set LAUNCHER_S
TART_PARAMS=-c;bin/launcher.json

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>rem ----------
---------------------------------------------------

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>if ""/install"
" == ""/install"" goto srvInstall

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>rem Install th
e ForgeRock Launcher as Windows service

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>shift

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>set SERVICE_NA
ME=ForgeRockLauncherJavaService

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>if not """" ==
"""" (set SERVICE_NAME= )

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>shift

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>set MAIN_CLASS
=org.forgerock.commons.launcher.Main

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>"C:\Users\Admi
nistrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin\amd64\prunsrv.exe" //IS//Fo
rgeRockLauncherJavaService --Install="C:\Users\Administrator\Desktop\openidm-2.1
.0-SNAPSHOT\openidm\bin\amd64\prunsrv.exe" --Description="ForgeRock OSGi Java Se
rver" --Jvm="C:\Program Files (x86)\Java\jre7\\jre\bin\server\jvm.dll" --Classpa
th=bin/launcher.jar;bin/felix.jar --JvmOptions=-Xmx1024m;-Djava.util.logging.con
fig.file=conf\logging.properties;-Dlogback.configurationFile=conf\logging-config
.xml;-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005; --Start
Path="C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm" --StartMode
=jvm --StartClass=org.forgerock.commons.launcher.Main --StartMethod=start --Star
tParams="" --StopMode=jvm --StopClass=org.forgerock.commons.launcher.Main --Stop
Method=stop --LogPath="C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\ope
nidm\logs" --LogPrefix=launcher --StdOutput=auto --StdError=auto --LogLevel=INFO

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>echo ForgeRock
Launcher Java Service successfully installed as "ForgeRockLauncherJavaService"
service
ForgeRock Launcher Java Service successfully installed as "ForgeRockLauncherJava
Service" service

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>goto :EOF

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>goto :EOF

C:\Users\Administrator\Desktop\openidm-2.1.0-SNAPSHOT\openidm\bin>

Comment by Tinghua.Xu [ 20/Aug/13 ]

error message when started the service

Comment by Tinghua.Xu [ 20/Aug/13 ]

event log

Comment by Tinghua.Xu [ 21/Aug/13 ]

It was found out that on the 64bit windows 2008 R2 server, only 32 bit Java was installed and start the service would generate the error
[2013-08-20 17:14:56] [info] Commons Daemon procrun (1.0.10.0 64-bit) started
[2013-08-20 17:14:56] [info] Service ForgeRockLauncherJavaService name
[2013-08-20 17:14:56] [info] Service 'ForgeRockLauncherJavaService' installed
[2013-08-20 17:14:56] [info] Commons Daemon procrun finished
[2013-08-20 17:15:11] [info] Commons Daemon procrun (1.0.10.0 64-bit) started
[2013-08-20 17:15:11] [info] Running 'ForgeRockLauncherJavaService' Service...
[2013-08-20 17:15:11] [info] Starting service...
[2013-08-20 17:15:11] [error] The specified module could not be found.
[2013-08-20 17:15:11] [error] Failed creating java C:\Program Files (x86)\Java\jre7\\jre\bin\server\jvm.dll
[2013-08-20 17:15:11] [error] The specified module could not be found.
[2013-08-20 17:15:11] [error] ServiceStart returned 1
[2013-08-20 17:15:11] [error] The specified module could not be found.
[2013-08-20 17:15:11] [info] Run service finished.
[2013-08-20 17:15:11] [info] Commons Daemon procrun finished

After installed 64bit server java, then start the service become fine.

Leave the ticket open as we'll make it work with 32 bit Java too.

Comment by Vincent Rioux [X] (Inactive) [ 26/May/14 ]

For what it's worth, using OpenIDM 2.1 Enterprise release, I managed to create myself the following installation script. It works perfectly and without installing anything more than the basic OpenIDM install. I made the batch file as self-explanatory as possible to make it possible to update the settings as needed. I used the Apache daemon help webpage to find out the good parameters :

http://commons.apache.org/proper/commons-daemon/procrun.html

installService.bat :

@ECHO OFF
REM UQAM
REM rioux.vincent@uqam.ca
REM 2014-05-26
REM
REM Install OpenIDM using prunsrv.exe
REM
REM OpenIDM path is E:\OpenIDM
REM
REM Java JRE VM path is C:\Program Files\Java\jre7\bin\server\jvm.dll
REM

E:
CD \OpenIDM

REM Expanded command for help :

REM "E:\OpenIDM\bin\amd64\prunsrv.exe" //IS//ForgeRockLauncherJavaService
REM --Install="E:\OpenIDM\bin\amd64\prunsrv.exe"
REM --Description="ForgeRock OSGi Java Server"
REM --Jvm="C:\Program Files\Java\jre7\bin\server\jvm.dll"
REM --Classpath=bin*;framework*
REM --JvmOptions=-Xmx3072m;-Dfile.encoding=UTF-8;-Djava.endorsed.dirs="";-Dopenidm.system.server.root="E:\OpenIDM";-Djava.util.logging.config.file=E:\OpenIDM\conf\logging.properties;-Djava.security.auth.login.config="E:\OpenIDM\security\jaas-repo.conf";-Dlogback.configurationFile=E:\OpenIDM\conf\logging-config.xml;-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005;
REM --StartPath="E:\OpenIDM"
REM --StartMode=jvm
REM --StartClass=org.forgerock.commons.launcher.Main
REM --StartMethod=start
REM --StartParams="-c;E:\OpenIDM\bin\launcher.json"
REM --StopMode=jvm
REM --StopClass=org.forgerock.commons.launcher.Main
REM --StopMethod=stop
REM --LogPath="E:\OpenIDM\logs"
REM --LogPrefix=launcher
REM --StdOutput=auto
REM --StdError=auto
REM --LogLevel=INFO
REM ++Environment="OPENIDM_HOME=E:\OpenIDM;CURRENT_DIR=E:\OpenIDM"

REM Concatenated on one line for call :

"E:\OpenIDM\bin\amd64\prunsrv.exe" //IS//ForgeRockLauncherJavaService --Install="E:\OpenIDM\bin\amd64\prunsrv.exe" --Description="ForgeRock OSGi Java Server" --Jvm="C:\Program Files\Java\jre7\bin\server\jvm.dll" --Classpath=bin*;framework* --JvmOptions=-Xmx3072m;-Dfile.encoding=UTF-8;-Djava.endorsed.dirs="";-Dopenidm.system.server.root="E:\OpenIDM";-Djava.util.logging.config.file=E:\OpenIDM\conf\logging.properties;-Djava.security.auth.login.config="E:\OpenIDM\security\jaas-repo.conf";-Dlogback.configurationFile=E:\OpenIDM\conf\logging-config.xml;-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005; --StartPath="E:\OpenIDM" --StartMode=jvm --StartClass=org.forgerock.commons.launcher.Main --StartMethod=start --StartParams="-c;E:\OpenIDM\bin\launcher.json" --StopMode=jvm --StopClass=org.forgerock.commons.launcher.Main --StopMethod=stop --LogPath="E:\OpenIDM\logs" --LogPrefix=launcher --StdOutput=auto --StdError=auto --LogLevel=INFO ++Environment="OPENIDM_HOME=E:\OpenIDM;CURRENT_DIR=E:\OpenIDM"

Comment by Nicolas Philippe [X] (Inactive) [ 10/Jul/14 ]

prunsrv.exe has been used for Identity Connect and works ok. It might need to be ported back to OpenIDM. But my preference, as discussed with you Mareks, is to use a type of self-installer. We had several requests from customers to make this service installation more user-friendly and "windows" like.

Comment by Andi Egloff [ 11/Jul/14 ]

OpenIDM was moved onto ForgeRock commons launcher, and in turn Apache Commons Daemon, specifically for the purpose of gaining support for running as a Windows service. It is bundled with the OpenIDM distribution. We should verify QA status of it.

Comment by Mareks Malnacs [ 11/Jul/14 ]

New bat script for a service installation is fine. Problem is with a service itself, once started, as windows services framework does communicate with a service a lot - it does not provide any means of status to be monitored and restarted if needed, or uninstalled, etc. Nor installer to be more user-friendly/"windows like". Plain MSI or InnoSetup script (as in AD sync) does provide only gui for the script to be installed. Nice service wrapper is still what is missing. We might need to see if the code/wrapper we did for opendj provides any benefit here.

Comment by Andi Egloff [ 11/Jul/14 ]

Mareks, I am not sure how to interpret your message.

Are you saying the commons daemon service wrapper is not sufficient?

Just to be clear, I am not referring to the current startup bat, which is not service based.

Comment by Mike Jang [X] (Inactive) [ 02/Nov/14 ]

When I try the install-service.bat command on W2008 and W2012, it adds a ForgeRockLauncherJava service, but it does not create or add an OpenIDM service

Comment by Mike Jang [X] (Inactive) [ 02/Nov/14 ]

When I try to start the ForgeRockLauncherJava service, I get the following error:

Windows could not start the ForgeRockLauncherJavaService on Local Computer. For more information, review the System Event Log. If this is a non-Microsoft service, contact the service vendor, and refer to service-specific error code 0.

eventlog.txt attached.

Comment by Brendan Miller [ 20/Oct/16 ]

Re-open if customer issue.

Comment by Quentin CASTEL [X] (Inactive) [ 20/Nov/16 ]

modification of the status, in order to migrate the 'Zendesk ID' field to 'Support Ticket ID' field.

Comment by Quentin CASTEL [X] (Inactive) [ 20/Nov/16 ]

modification of the status, in order to migrate the 'Zendesk ID' field to 'Support Ticket ID' field.

Generated at Sun Sep 27 07:14:57 UTC 2020 using Jira 7.13.12#713012-sha1:6e07c38070d5191bbf7353952ed38f111754533a.