Search code examples
javawindows-servicesprocrun

Procrun logs "missing Service ImageFile" (error code 1)


I try to install a JAR file as a windows service using Apache Commons Procrun. The service gets installed, but executing it gives me the following error:

[2018-02-26 14:00:26] [info]  [38792] Starting service...
[2018-02-26 14:00:26] [error] [38792] Missing service ImageFile
[2018-02-26 14:00:26] [error] [38792] ServiceStart returned 1
[2018-02-26 14:00:26] [info]  [38816] Run service finished.
[2018-02-26 14:00:26] [info]  [38816] Commons Daemon procrun finished

My configuration looks like (it's inside a batch file):

set SERVICE_NAME=Deamon
set BASE=c:\GIT\companyProject\myProject
set PR_INSTALL=%BASE%\deamon\prunsrv.exe

REM Service log configuration
set PR_LOGPREFIX=%SERVICE_NAME%
set PR_LOGPATH=c:\Logs\Deamon\logs
set PR_STDOUTPUT=c:\Logs\Deamon\stdout.txt
set PR_STDERROR=c:\Logs\Deamon\stderr.txt
set PR_LOGLEVEL=Error

REM Path to java installation
set PR_JVM=%BASE%\jre1.8.0_151\bin\java.exe
set PR_CLASSPATH=%BASE%\target\myProject.jar

REM Startup configuration
set PR_STARTUP=auto
set PR_STARTMODE=jvm
set PR_STARTCLASS=com.myProject.deamon.Main
set PR_STARTMETHOD=start

REM Shutdown configuration
set PR_STOPMODE=jvm
set PR_STOPCLASS=com.myProject.deamon.Main
set PR_STOPMETHOD=stop

REM JVM configuration
set PR_JVMMS=256
set PR_JVMMX=4000
set PR_JVMSS=8000
set PR_JVMOPTIONS=-Duser.language=DE;-Duser.region=de
REM Install service

deamon\%SERVICE_NAME%.exe //IS//%SERVICE_NAME%

There are similar questions on SO, but I cannot find any answer to the "missing service ImageFile" error (no official documents on this topic either). Although I would consider myself somewhat experienced at coding, I have no idea where this error comes from. Any help would be appreciated.


Solution

  • I got past this by adding the following to your configuration service.bat:

    set PR_STARTIMAGE=C:\procrun\itiIcon.ico
    set PR_STOPIMAGE=C:\procrun\itiIcon.ico