executeCommandLine fails with Java exception "Failed to exec spawn helper"

  • Platform information:
    • Hardware: Raspberry PI4, 4GB RAM
    • OS: Linux/6.1.21-v8+ (aarch64)
    • Java Runtime Environment: OpenJDK Runtime Environment (build 17.0.10+7-Debian-1deb11u1)
    • openHAB version: openHAB 4.0.4
  • Issue of the topic: I have a rule, that used to work fine, but at “some” point it started to fail. The only thing that rule does is executing the Bash script. When I run this script manually via command line it runs without any errors, but when through executeCommandLine within the rule it ends with a Java exception:

2024-02-08 09:01:00.294 [WARN ] [rg.openhab.core.io.net.exec.ExecUtil] - Error occurred when executing commandLine ‘[/home/openhabian/script.bash]’
java.io.IOException: Cannot run program “/home/openhabian/script.bash”: error=0, Failed to exec spawn helper: pid: 2102616, signal: 11
Below is the rule code:

rule scriptRefresh
when
    Time cron "0 0/1 * * * ? *"
then
    var ScriptResponse = executeCommandLine("/home/openhabian/script.bash")
	logInfo("test", "Results " + ScriptResponse)
end

What could be the issue?

Hi @WojtusJ, looked at this one last night, and this suggestion worked for me:

TLDR: Add -Djdk.lang.Process.launchMechanism=vfork to openhab launch command line.

Thanks for quick response. I’m not that advance in this stuff, what does it mean “add to openhab launch command line”? Should I modify some OpenHab source files? If yes, where to find them?

please try


var ScriptResponse = executeCommandLine(Duration.ofSeconds(1), "/home/openhabian/script.bash")

and make sure permissions are correctly set for script.bash

I think on openhabian you can modify /etc/profile/openhab and add this parameter to a line that starts with something like JAVA_EXTRA_ARGS

Disclaimer: Not in front of my rasbpi atm so syntax is likely wrong.

I have googled in the meantime and added your solution in the file /etc/default/openhad, where also I could find EXTRA_JAVA_OPTS. Now it works! Thank you very much. :slight_smile:

Hey thanks everyone in this thread!!! I have a script that I execute with openhab to change the volume on my media center computer (separate from my openhab computer) to an item value and somehow had not noticed that sense java was upgraded to version 14 on my openhab machine that it was failing with a similar error to WojtusJ. I edited /etc/default/openhab and added the above to the file so that the line now looks like this:

EXTRA_JAVA_OPTS="-Djdk.lang.Process.launchMechanism=vfork"

Then accidentally blasted my eardrums by selecting too high of a volume after a reset of my openhab service. Thanks again!
Sean