Starting OH2 with openhab-cli works but not with systemctl so not autostarting

  • Platform information:
    • Hardware: RPi(3)
    • OS: OpenHabian
    • Java Runtime Environment: Zulu8
    • openHAB version: 2.5.10

Just installed brand new sdcard with latest image. Openhab2 wasn’t enabled by default (should it not be?) so I enabled by sudo systemctl enable openhab2. So I tried to launch with sudo systemctl start openhab2 but get errors:

[02:00:25] openhabian@demeter:/var/log/openhab2$ sudo systemctl start openhab2.service
Job for openhab2.service failed because the control process exited with error code.
See “systemctl status openhab2.service” and “journalctl -xe” for details.

[02:00:04] openhabian@demeter:/var/log/openhab2$ systemctl status openhab2.service
● openhab2.service - openHAB2 instance, reachable at http://demeter:8080
Loaded: loaded (/usr/lib/systemd/system/openhab2.service; enabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/openhab2.service.d
└─override.conf
Active: activating (start-post) (Result: exit-code) since Sat 2020-12-12 02:00:15 GMT; 7s ago
Docs: https://www.openhab.org/docs/
https://community.openhab.org
Process: 9649 ExecStartPre=/bin/bash -c /usr/bin/find ${OPENHAB_CONF} -name “*.rules” -exec /usr/bin/rename.ul .rules .x {} ; (code=exited, status=0/SU
Process: 9652 ExecStart=/usr/share/openhab2/runtime/bin/karaf ${OPENHAB_STARTMODE} (code=exited, status=255/EXCEPTION)
Main PID: 9652 (code=exited, status=255/EXCEPTION); Control PID: 9653 (sleep)
Tasks: 1 (limit: 2182)
CGroup: /system.slice/openhab2.service
└─9653 /bin/sleep 120

Dec 12 02:00:19 demeter karaf[9652]: at org.eclipse.osgi.storage.Storage.getChildStorageManager(Storage.java:1776)
Dec 12 02:00:19 demeter karaf[9652]: at org.eclipse.osgi.storage.Storage.getInfoInputStream(Storage.java:1793)
Dec 12 02:00:19 demeter karaf[9652]: at org.eclipse.osgi.storage.Storage.(Storage.java:132)
Dec 12 02:00:19 demeter karaf[9652]: at org.eclipse.osgi.storage.Storage.createStorage(Storage.java:85)
Dec 12 02:00:19 demeter karaf[9652]: at org.eclipse.osgi.internal.framework.EquinoxContainer.(EquinoxContainer.java:68)
Dec 12 02:00:19 demeter karaf[9652]: at org.eclipse.osgi.launch.Equinox.(Equinox.java:31)
Dec 12 02:00:19 demeter karaf[9652]: at org.eclipse.osgi.launch.EquinoxFactory.newFramework(EquinoxFactory.java:24)
Dec 12 02:00:19 demeter karaf[9652]: at org.apache.karaf.main.Main.launch(Main.java:256)
Dec 12 02:00:19 demeter karaf[9652]: at org.apache.karaf.main.Main.main(Main.java:178)
Dec 12 02:00:19 demeter systemd[1]: openhab2.service: Main process exited, code=exited, status=255/EXCEPTION

If I launch it with sudo openhab-cli start it will start and load the PaperUI but then as soon as I log out, it all stops. Trying systemctl option just doesn’t work. Of course this is annoying as autostart is not working.

Any clues?

What is the output of

journalctl -xe

and what is the content of /var/log/openhab/openhab.log ?

It could be that it is a permission problem in case you once started openhab under root.
Run

sudo openhab-cli reset-ownership

Thank you. Seems to have solve the problem. Not quite sure how I would have started the service as root given that I have always run started the service as user openhabian using sudo. I guess it doesn’t matter now that it works. Just maybe worth knowing in case I have to reinstall again in the future.