I've used jpackage to create an exe file that I register with following apache commons daemon command as a windows service:
prunsrv.exe //IS/my-service --Description="My Client" --StartPath="E:\clients\my-client" --StartMode=exe --StartImage="E:\clients\my-client\my-client.exe" --Startup=auto --Jvm=auto --LogPath="E:\clients\my-client\logs"
I'm then able to start my java application as a windows service.
When I stop the service, then it gets stopped, but I'm getting following Windows Service error: "Windows could not stop the my-service 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 -331350696." (the error code changes every time I stop the service)
I don't see any information in the daemon logs:
[2025-02-17 09:28:17] [info] [23392] Apache Commons Daemon procrun (1.4.1.0 64-bit) started.
[2025-02-17 09:28:18] [info] [23392] Running Service 'my-service'...
[2025-02-17 09:28:18] [info] [16644] Starting service...
[2025-02-17 09:28:18] [info] [16644] Service started in 15 milliseconds.
[2025-02-17 09:28:23] [info] [23392] Service SERVICE_CONTROL_STOP signalled.
[2025-02-17 09:28:23] [info] [17272] Stopping service...
[2025-02-17 09:28:24] [info] [23392] Run service finished.
[2025-02-17 09:28:24] [info] [23392] Apache Commons Daemon procrun finished.
The application logs indicate that the service was simply killed. As no shutdown hooks or anything are called (which would then log some additional information).
Do I miss something when installing the service? I would expect to be able to stop the service without an error message and have it shutdown normally instead of killed.