[SOLVED] Openhab2.service: Failed with result 'exit-code'

Hi,

Completely new to Raspberry and Openhab.

I managed to set up Raspbian Lite on my RasPI3B which seems to run ok.

Then manually downloaded and installed Zulu embeded Java libraries - v8 (as mentioned on the Openhab Installation Overview page). Installed to…

/usr/lib/jvm/zulu-8

I set up the JAVA_HOME environment variable, updated the PATH and running java -version I get back…

openjdk version "1.8.0_172"
OpenJDK Runtime Environment (Zulu Embedded 8.30.0.106-linux-aarch32hf) (build 1.8.0_172-106)
OpenJDK Client VM (Zulu Embedded 8.30.0.106-linux-aarch32hf) (build 25.172-b106, mixed mode, Evaluation)

Continued to openHab install, using the online package method which seemed to go well, but when checking the status after starting I get the following…

● openhab2.service - openHAB 2 - empowering the smart home
** Loaded: loaded (/usr/lib/systemd/system/openhab2.service; enabled; vendor preset: enabled)**
** Active: activating (auto-restart) (Result: exit-code) since Fri 2018-05-25 09:55:07 UTC; 440ms ago**
** Docs: http://docs.openhab.org**
** https://community.openhab.org**
** Process: 1141 ExecStop=/usr/share/openhab2/runtime/bin/karaf stop (code=exited, status=1/FAILURE)**
** Process: 1123 ExecStart=/usr/share/openhab2/runtime/bin/karaf $OPENHAB_STARTMODE (code=exited, status=1/FAILURE)**
** Main PID: 1123 (code=exited, status=1/FAILURE)**
May 25 09:55:07 openhabpi systemd[1]: openhab2.service: Failed with result ‘exit-code’.

When I check the logs, there’s nothing in /var/log/openhab2 folder, which suggests the process hasn’t even had a chance to start.

When I check the daemon.log, I see a lot of these events…

May 25 09:57:45 openhabpi systemd[1]: Started openHAB 2 - empowering the smart home.
May 25 09:57:45 openhabpi karaf[2250]: java command not found
May 25 09:57:45 openhabpi systemd[1]: openhab2.service: Main process exited, code=exited, status=1/FAILURE
May 25 09:57:45 openhabpi karaf[2268]: java command not found
May 25 09:57:45 openhabpi systemd[1]: openhab2.service: Control process exited, code=exited status=1
May 25 09:57:45 openhabpi systemd[1]: openhab2.service: Unit entered failed state.
May 25 09:57:45 openhabpi systemd[1]: openhab2.service: Failed with result ‘exit-code’.
May 25 09:57:50 openhabpi systemd[1]: openhab2.service: Service hold-off time over, scheduling restart.
May 25 09:57:50 openhabpi systemd[1]: Stopped openHAB 2 - empowering the smart home.

Is there anywhere I can check to see what java command is being attempted? Or is it clear that the Java install is the issue?

Platform information:

  • Hardware: Raspberry PI 3B+
  • OS: RASPBIAN STRETCH LITE
  • Java Runtime Environment: Zulu Embedded 1.8.0_172
  • openHAB version: 2.2

Cheers,
Henryk.

I’m going to recommend using openHABian which is Raspbian Lite with some scripts that will automatically install and configure OH and everything that OH needs. It will greatly lessen the amount of work you need to do to get started and it will help you avoid these sorts of problems.

Presumably you set this environment variable for the pi user. Unfortunately that only will apply to the pi user. OH rns as the openhab user. But if you had to set the environment variable at all means that your install of Zulu either was not standard or it failed.

1 Like

Thanks Rich.

I did consider openHABian, but thought I might go on a bit of a linux journey, which I’m starting to think might’ve been a bad idea :grinning:

But your other point made me question the Zulu java setup, and after doing some more digging, I found that I failed to add Zulu JVM to the list of alternate VMs:

sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/zulu-8/bin/java 1000
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/zulu-8/bin/javac 1000

Once I did this and restarted the openHab2 service started successfully.

● openhab2.service - openHAB 2 - empowering the smart home
** Loaded: loaded (/usr/lib/systemd/system/openhab2.service; enabled; vendor preset: enabled)**
** Active: active (running) since Sun 2018-05-27 21:55:24 AEST; 2min 22s ago**
** Main PID: 625 (java)**
** CGroup: /system.slice/openhab2.service**
** └─625 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab.runtime=/usr/share/openhab2/runtime -Dopenhab.user**

Happy days for now, onto the next stage of the journey.

Cheers,
H

Same issue, same solution, except that I needed to update the path for the current (as of 9/2020) version of Zulu JVM. The difference is the folder name in /usr/lib/jvm: “zulu-14-amd64”.

This solution worked for me as well after upgrading from OH2 to OH3. The difference is that I had to install to zulu11 folder instead of zulu-8. Then a quick reinstall of openhab fixed it.

sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/zulu11/bin/java 1000
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/zulu11/bin/javac 1000
sudo apt-get install --reinstall openhab
sudo /bin/systemctl start openhab.service

Thanks for the hint, @jay343.