On 01/09/2020 17:31, Jan Patrick Lübbert wrote: <snip/>
> I tried the JVM mode with the service config (arguments as array in a > PowerShell script): > > "install", > "MyService", > "--DisplayName=""My Service""", > "--JavaHome=""$RootPath\jre""", > "--Jvm=""$RootPath\jre\bin\client\jvm.dll""", > "--StartMode=jvm", > "--StopMode=jvm", > "--JvmOptions9=""--module-path modules""", > "++JvmOptions9=""--module de.my.package/de.my.package.Main""", > "--StartClass=de.my.package.Main", > "--StopClass=de.my.package.Main", > "--StopTimeout=300", > "--JvmMs=128", > "--JvmMx=1024", > "--JvmSs=128", > "--LogPath=$RootPath\log", > "--LogPrefix=service", > "--LogLevel=Debug", > "--StdOutput=auto", > "--StdError=auto", > "--StartPath=$RootPath", > "--Startup=auto", > "--LogJniMessages=1" > > The log output: > > ( prunsrv.c:1763) [ 5048] Apache Commons Daemon procrun log initialized. > ( prunsrv.c:1767) [ 5048] Apache Commons Daemon procrun (1.2.2.0 64-bit) > started. > ( prunsrv.c:621 ) [ 5048] Installing service... > ( prunsrv.c:660 ) [ 5048] Installing service 'MyService' name 'My Service'. > ( prunsrv.c:694 ) [ 5048] Service 'MyService' installed. > ( prunsrv.c:1848) [ 5048] Apache Commons Daemon procrun finished. > ( prunsrv.c:1763) [ 7308] Apache Commons Daemon procrun log initialized. > ( prunsrv.c:1767) [ 7308] Apache Commons Daemon procrun (1.2.2.0 64-bit) > started. > ( prunsrv.c:1677) [ 7308] Running Service 'MyService'... > ( prunsrv.c:1448) [ 4548] Inside ServiceMain... > ( prunsrv.c:910 ) [ 4548] reportServiceStatusE: dwCurrentState = 2, > dwWin32ExitCode = 0, dwWaitHint = 3000, dwServiceSpecificExitCode = 0. > ( prunsrv.c:1203) [ 4548] Starting service... > ( javajni.c:216 ) [ 4548] Explicit RuntimeLib specified > 'D:\MyService\jre\bin\client\jvm.dll' > ( javajni.c:285 ) [ 4548] loading jvm 'D:\MyService\jre\bin\client\jvm.dll' > ( javajni.c:795 ) [ 5688] Jvm Option[0] vfprintf > ( javajni.c:795 ) [ 5688] Jvm Option[1] --module-path modules > ( javajni.c:795 ) [ 5688] Jvm Option[2] --module > de.my.package/de.my.package.Main > ( javajni.c:795 ) [ 5688] Jvm Option[3] exit > ( javajni.c:795 ) [ 5688] Jvm Option[4] abort > ( javajni.c:795 ) [ 5688] Jvm Option[5] -Xms128m > ( javajni.c:795 ) [ 5688] Jvm Option[6] -Xmx1024m > ( javajni.c:795 ) [ 5688] Jvm Option[7] -Xss128k > ( javajni.c:536 ) [ 5688] Unrecognized option: --module-path modules > ( javajni.c:806 ) [ 5688] CreateJavaVM Failed with error [-1] > ( javajni.c:806 ) [ 5688] Das System kann die angegebene Datei nicht finden. > ( javajni.c:1057) [ 5688] Java Worker thread finished : with status = 2 > ( prunsrv.c:1258) [ 4548] Failed to start Java > ( prunsrv.c:1611) [ 4548] ServiceStart returned 4. > ( prunsrv.c:910 ) [ 4548] reportServiceStatusE: dwCurrentState = 1, > dwWin32ExitCode = 1066, dwWaitHint = 0, dwServiceSpecificExitCode = 4. > ( prunsrv.c:1679) [ 7308] Run service finished. > ( prunsrv.c:1848) [ 7308] Apache Commons Daemon procrun finished. > > If I change Jvm to java.exe and StartMode to Java the stderr log states: > > 2020-09-01 18:18:10 Apache Commons Daemon procrun stderr initialized. > NOTE: Picked up JDK_JAVA_OPTIONS: --module-path modules --module > de.my.package/de.my.package.Main > > Error: Option --module is not allowed in environment variable > JDK_JAVA_OPTIONS > > What am I doing wrong? At first glance nothing. That is pretty much exactly what I tried first when I set this up to test locally. And my test environment isn't work either. The good news is that with a few changes it should be possible to get this working. At least, I got my simple test working. The first change is the module path. As documented in [1] you need to use: --module-path=modules (note the addition of the equals) The second is how you define the main module. As documented in [2] you need to use: -Djdk.module.main=module So my full config was: prunsrv.exe install --DisplayName "Test" --JavaHome "C:\java\adopt-14.0.2+12" --Jvm "C:\java\adopt-14.0.2+12\bin\server\jvm.dll" --JvmOptions "" --JvmOptions9 "--module-path=C:\Users\god\Documents\bin#-Djdk.module.main=test" --JvmMs 128 --JvmMx 256 --JvmSs 0 --StopPath "C:\Users\god\Documents\bin" --StopClass "org.apache.markt.Test" --StopParams "" --StopTimeout 0 --StartPath "C:\Users\god\Documents\bin" --StartClass "org.apache.markt.Test" --StartParams "" --StartMode "jvm" --LogPath "C:\Users\god\Documents\bin" --LogPrefix "commons-daemon" --LogLevel "Debug" --StdError "auto" --StdOutput "auto" --LogJniMessages 0 --Rotate 0 where the equivalent command line was: java --module-path . --module test/org.apache.markt.Test HTH, Mark [1] https://bugs.openjdk.java.net/browse/JDK-8227497 [2] https://community.oracle.com/thread/4135394 --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org