I'm using Apache Commons Procrun (prunsrv.exe, renamed testService.exe) to install a .jar as a windows service. It installs the service successfully, and it appears in the Windows Service Manager.
When I try to start the service, it fails. Here's the commons-daemon log with the associated errors:
[2019-01-14 09:52:52] [info] [12988] Commons Daemon procrun (1.1.0.0 64-bit) started
[2019-01-14 09:52:52] [info] [12988] Starting service 'testService' ...
[2019-01-14 09:52:52] [warn] [12988] Failed to obtain service description
[2019-01-14 09:52:56] [error] [12988] apxServiceControl(): dwState(4) != dwCurrentState(1); dwWin32ExitCode = 1066, dwWaitHint = 0, dwServiceSpecificExitCode = 1
[2019-01-14 09:52:56] [error] [12988] apxServiceControl(): returning FALSE
[2019-01-14 09:52:56] [error] [12988] Failed to start service 'testService'
[2019-01-14 09:52:56] [info] [12988] Start service finished, returning 0
[2019-01-14 09:52:56] [error] [12988] Commons Daemon procrun failed with exit value: 5 (Failed to start service)
Here's the script I wrote which installs/starts the service:
@echo off
SET SERVICE_NAME=testService
IF "%1%" == "start" GOTO START
IF "%1%" == "stop" GOTO STOP
IF "%1%" == "delete" GOTO DELETE
IF "%1%" NEQ "install" GOTO:EOF
SET PR_INSTALL="%~dp0testService.exe"
SET PR_CLASSPATH=testService.jar
SET PR_JVM=%JAVA_HOME%\jre\bin\server\jvm.dll
SET PR_STARTUP=auto
SET PR_STARTMODE=jvm
SET PR_STARTCLASS=com.testService
SET PR_STARTPARAM=start
SET PR_STOPMODE=jvm
SET PR_STOPCLASS=com.testService
SET PR_STOPPARAM=stop
%SERVICE_NAME%.exe install %SERVICE_NAME%
GOTO:EOF
:START
%SERVICE_NAME%.exe start %SERVICE_NAME%
GOTO:EOF
:STOP
%SERVICE_NAME%.exe stop %SERVICE_NAME%
GOTO:EOF
:DELETE
%SERVICE_NAME%.exe delete %SERVICE_NAME%
Any ideas what that error might mean? I can't seem to find any information about this, and It's driving me nuts.
The problem was with the %SERVICE_NAME%.exe install %SERVICE_NAME%
calls
I replaced them with testService.exe install %SERVICE_NAME%
and the service starts as expected.