Reputation: 5113
Trying out Apache procrun I see a behaviour that I do not understand. It boils down to the main
method of the Java program throwing an exception. This is not logged anywhere and the Windows service does not stop. To investigate further I changed the main
method to
public static void main(String[] args) throws Exception {
if (args.length<10000000) {
throw new Exception("one exception right away");
}
...
}
When I install this as a service with prunsrv.exe
and then start it, it starts without problems and produces no log output whatsoever. In particular the service does not stop.
For reference, here is how the service is installed with procrun:
& $procrun "//$operation//$service" `
--DisplayName="$service" `
--Description="$service" `
--DependsOn="$depends" `
--Startup=auto `
--Install="$procrun" `
--Jvm="$JVM" `
--Classpath="$cp" `
--Environment="PATH=$env:JAVA_HOME\bin" `
--JavaHome="$env:JAVA_HOME" `
--StartPath="c:\Search" `
--JvmOptions="-Xmx512M;-Xms512M;-Djava.awt.headless=true" `
--StartMode="jvm" `
--StartClass="$classname" `
--LogPath="c:\Search\std-logs" `
--LogPrefix="procrun-$service" `
--LogLevel="Debug" `
--StdError="c:\Search\std-logs\stderr-$no0" `
--StdOutput="c:\Search\std-logs\stdout-$no0" `
--StartParams="(unused)"
I would have expected that the service stops right away and I find some log output in the stderr/stdout files, but nothing. Can anyone explain this?
EDIT: Oh my, it seems like procrun
swallows java.lang.Error
(in my case java.lang.noClassDefFoundError
) instead of screaming, shouting and exiting.
Upvotes: 2
Views: 784
Reputation: 5113
After I wrapped a catch(Throwable)
around the main, logging whatever popped out and then exiting without re-throwing, I saw the problem. I got a java.lang.NoClassDefFoundError
.
Bottom line: procrun
seems to swallow error type exceptions and does not even terminate if one is thrown in the called Java program.
Created an issue: https://issues.apache.org/jira/browse/DAEMON-344
Upvotes: 1