[SOLVED] "Failed to start The openHAB 2 Home Automation Bus Solution."

Hello people, just wanted to share the fix to this as I didn’t find it anywhere else.

> ● openhab2.service - The openHAB 2 Home Automation Bus Solution
>    Loaded: loaded (/lib/systemd/system/openhab2.service; enabled; vendor preset: enabled)
>    Active: inactive (dead) (Result: exit-code) since Thu 2016-09-01 21:11:52 EST; 33s ago
>      Docs: http://docs.openhab.org
>   Process: 3101 ExecStart=/opt/openhab2/start.sh server (code=exited, status=200/CHDIR)
>  Main PID: 3101 (code=exited, status=200/CHDIR)

> Sep 01 21:11:52 openHAB systemd[1]: openhab2.service: Unit entered failed state.
> Sep 01 21:11:52 openHAB systemd[1]: openhab2.service: Failed with result 'exit-code'.
> Sep 01 21:11:52 openHAB systemd[1]: openhab2.service: Service hold-off time over, scheduling restart.
> Sep 01 21:11:52 openHAB systemd[1]: Stopped The openHAB 2 Home Automation Bus Solution.
> Sep 01 21:11:52 openHAB systemd[1]: openhab2.service: Start request repeated too quickly.
> Sep 01 21:11:52 openHAB systemd[1]: Failed to start The openHAB 2 Home Automation Bus Solution.

After troubleshooting for a while, I noticed the file /lib/systemd/system/openhab2.service was pointing to /opt/openhab2 (manual installations) instead of /usr/share/openhab2 (repository installation, the way I installed) for no apparent reason, so I just corrected the 2 lines on the file showing the wrong path, ran sudo systemctl daemon-reload and sudo systemctl start openhab2, which solved the problem.

This was very weird tho, I am not really sure why the path would change, I never installed manually and didnt have any issues when restarting the service previously.

I am running OH2 on Ubuntu Server 16.04 LTS.

Hope this helps someone else.

2 Likes

Hey @m3ld0n, the fact, that your quote includes “The openHAB 2 Home Automation Bus Solution” makes me believe that this is in fact the service file left over from a previous manual installation. This string is only used here but it is different in the service file provided by the repository based installation.
If I’m right so far, can it be you missed to delete the service file when you removed your manual setup (as described here)?

1 Like

I had the same problem. Indeed the workingdirectory and ExecStart locations were wrong.
Thx for the hint!

2 Likes

I have done an apt-get installation on raspberry pi with offline mode ( sudo apt-get install openhab2-offline), and I have been faced with the same problem. The described fix resolved my issue.
I must stress that the service did start 4 or 5 times without a problem.
The only changes I did where via the web interface (enabling mqtt)

Hope this helps.

Amir

1 Like

Thanks, that sorted me out too.
Changed it so:
WorkingDirectory=/usr/share/openhab2
ExecStart=/usr/share/openhab2/start.sh server

Also, if, like me you’d deleted the /userdata directory, you need to put it back with the right permissions:
I found what the service was erroring on by looking at: /var/log/syslog

sudo mkdir /usr/share/openhab2/userdata
sudo mkdir /usr/share/openhab2/userdata/tmp
sudo mkdir /usr/share/openhab2/userdata/etc

sudo chown openhab:openhab userdata
sudo chown openhab:openhab userdata\tmp
sudo chown openhab:openhab userdata\etc

cheers

I followed the installation instructions at http://docs.openhab.org/installation/linux.html#installation and I’m getting an error when I run sudo systemctl status openhab2.service, it gives me:

Jun 10 00:10:06 chasiu stop[4866]: /usr/share/openhab2/runtime/bin/karaf: line 261: [: : integer expression expected
Jun 10 00:10:06 chasiu stop[4866]: /usr/share/openhab2/runtime/bin/karaf: line 306: [: : integer expression expected
Jun 10 00:10:06 chasiu stop[4866]: /usr/share/openhab2/runtime/bin/karaf: line 497: ./bin/java: No such file or directory
Jun 10 00:10:06 chasiu systemd[1]: openhab2.service: Control process exited, code=exited status=127
Jun 10 00:10:06 chasiu systemd[1]: openhab2.service: Unit entered failed state.
Jun 10 00:10:06 chasiu systemd[1]: openhab2.service: Failed with result 'exit-code'.
Jun 10 00:10:06 chasiu systemd[1]: openhab2.service: Service hold-off time over, scheduling restart.
Jun 10 00:10:06 chasiu systemd[1]: Stopped openHAB 2 - empowering the smart home.
Jun 10 00:10:06 chasiu systemd[1]: openhab2.service: Start request repeated too quickly.
Jun 10 00:10:06 chasiu systemd[1]: Failed to start openHAB 2 - empowering the smart home.

Running Ubuntu 16.04 LTS Server on VMWare ESXi 6.5. I’m a linux noob so I really don’t know what I’m doing - just following directions! Thanks for any help!!

EDIT: Nevermind, I realized I didn’t install Java. Followed the DigitalOcean instructions here to install Oracle JDK: https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-get-on-ubuntu-16-04
Result:

Jun 10 00:22:27 chasiu start.sh[6144]: Launching the openHAB runtime…

You could always use openHABian in “Manual Setup” mode on your Ubuntu system btw.

I found a solution and posted it here: Check if OpenHAB is running - Invalid command '' received

I installed my open hab on a fredhly installed debian system and started openhab one time

Then I did all acording https://docs.openhab.org/installation/linux.html#service
to get it as a service

I fited the file:
nano /lib/systemd/system/openhab2.service

[Unit]
Description=The openHAB 2 Home Automation Bus Solution
Documentation=http://docs.openhab.org
Wants=network-online.target
After=network-online.target

[Service]
Type=simple
User=openhab
Group=openhab
GuessMainPID=yes
WorkingDirectory=/usr/share/openhab2
#EnvironmentFile=/etc/default/openhab2
ExecStart=/usr/share/openhab2/start.sh server
ExecStop=/bin/kill -SIGINT $MAINPID
Restart=on-failure

[Install]
WantedBy=multi-user.target

but the servis doesn’t start:

root@srvHome01:/# systemctl daemon-reload
root@srvHome01:/# systemctl start openhab2.service
root@srvHome01:/# systemctl status openhab2.service
● openhab2.service - The openHAB 2 Home Automation Bus Solution
Loaded: loaded (/lib/systemd/system/openhab2.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2018-05-20 18:55:23 CEST; 5s ago
Docs: http://docs.openhab.org
Process: 3872 ExecStop=/bin/kill -SIGINT $MAINPID (code=exited, status=1/FAILURE)
Process: 3782 ExecStart=/usr/share/openhab2/start.sh server (code=exited, status=1/FAILURE)
Main PID: 3782 (code=exited, status=1/FAILURE)

Mai 20 18:55:23 srvHome01 systemd[1]: openhab2.service: Control process exited, code=exited status=1
Mai 20 18:55:23 srvHome01 systemd[1]: openhab2.service: Unit entered failed state.
Mai 20 18:55:23 srvHome01 systemd[1]: openhab2.service: Failed with result ‘exit-code’.
Mai 20 18:55:23 srvHome01 systemd[1]: openhab2.service: Service hold-off time over, scheduling restart
Mai 20 18:55:23 srvHome01 systemd[1]: Stopped The openHAB 2 Home Automation Bus Solution.
Mai 20 18:55:23 srvHome01 systemd[1]: openhab2.service: Start request repeated too quickly.
Mai 20 18:55:23 srvHome01 systemd[1]: Failed to start The openHAB 2 Home Automation Bus Solution.
Mai 20 18:55:23 srvHome01 systemd[1]: openhab2.service: Unit entered failed state.
Mai 20 18:55:23 srvHome01 systemd[1]: openhab2.service: Failed with result ‘exit-code’.

what is wrong? where can I serch for the fault?

If I start it manually with

root@srvHome01:/# openhab-cli start
A systemd service configuration exists…
Use ‘sudo /bin/systemctl start openhab2.service’ to start an openHAB service
Launching an instance in this terminal…
Launching the openHAB runtime…

                      __  _____    ____

____ ____ ___ ____ / / / / | / __ )
/ __ / __ / _ / __ / // / /| | / __ |
/ /
/ / // / __/ / / / __ / ___ |/ // /
_/ ./_// /// /// |/_____/
/_/ 2.2.0
Release Build

Hit ‘’ for a list of available commands
and ‘[cmd] --help’ for help on a specific command.
Hit ‘’ or type ‘system:shutdown’ or ‘logout’ to shutdown openHAB.

openhab>

openhab runs

Please halp me a little

Maybe here can be the mistake recognized:

root@srvHome01:/# journalctl -xe
Mai 20 19:17:01 srvHome01 systemd[1]: Stopped The openHAB 2 Home Automation Bus Solution.
– Subject: Unit openhab2.service has finished shutting down
– Defined-By: systemd
– Support: h t t p s ://w w w - debian - org/support

– Unit openhab2.service has finished shutting down.
Mai 20 19:17:01 srvHome01 systemd[1]: Started The openHAB 2 Home Automation Bus Solution.
– Subject: Unit openhab2.service has finished start-up
– Defined-By: systemd
– Support: h t t p s ://w w w - debian - org/support

– Unit openhab2.service has finished starting up.

– The start-up result is done.
Mai 20 19:17:01 srvHome01 start.sh[1778]: Launching the openHAB runtime…
Mai 20 19:17:01 srvHome01 start.sh[1778]: mkdir: das Verzeichnis „/usr/share/openhab2/userdata/tmp“ kan
Mai 20 19:17:02 srvHome01 start.sh[1778]: KARAF_BASE is not valid: /usr/share/openhab2/userdata
Mai 20 19:17:02 srvHome01 systemd[1]: openhab2.service: Main process exited, code=exited, status=1/FAIL
Mai 20 19:17:02 srvHome01 kill[1868]: Usage:
Mai 20 19:17:02 srvHome01 kill[1868]: kill [options] […]
Mai 20 19:17:02 srvHome01 kill[1868]: Options:
Mai 20 19:17:02 srvHome01 kill[1868]: […] send signal to every listed
Mai 20 19:17:02 srvHome01 kill[1868]: -, -s, --signal
Mai 20 19:17:02 srvHome01 kill[1868]: specify the to be sent
Mai 20 19:17:02 srvHome01 kill[1868]: -l, --list=[] list all signal names, or convert one to
Mai 20 19:17:02 srvHome01 kill[1868]: -L, --table list all signal names in a nice table
Mai 20 19:17:02 srvHome01 kill[1868]: -h, --help display this help and exit
Mai 20 19:17:02 srvHome01 kill[1868]: -V, --version output version information and exit
Mai 20 19:17:02 srvHome01 kill[1868]: For more details see kill(1).
Mai 20 19:17:02 srvHome01 systemd[1]: openhab2.service: Control process exited, code=exited status=1
Mai 20 19:17:02 srvHome01 systemd[1]: openhab2.service: Unit entered failed state.
Mai 20 19:17:02 srvHome01 systemd[1]: openhab2.service: Failed with result ‘exit-code’.
Mai 20 19:17:02 srvHome01 systemd[1]: openhab2.service: Service hold-off time over, scheduling restart.
Mai 20 19:17:02 srvHome01 systemd[1]: Stopped The openHAB 2 Home Automation Bus Solution.
– Subject: Unit openhab2.service has finished shutting down
– Defined-By: systemd
– Support: h t t p s://w w w - debian - org/support

– Unit openhab2.service has finished shutting down.
Mai 20 19:17:02 srvHome01 systemd[1]: openhab2.service: Start request repeated too quickly.
Mai 20 19:17:02 srvHome01 systemd[1]: Failed to start The openHAB 2 Home Automation Bus Solution.
– Subject: Unit openhab2.service has failed
– Defined-By: systemd
– Support: h t t p s:// w w w . d e b i an.org/support

– Unit openhab2.service has failed.

– The result is failed.
Mai 20 19:17:02 srvHome01 systemd[1]: openhab2.service: Unit entered failed state.
Mai 20 19:17:02 srvHome01 systemd[1]: openhab2.service: Failed with result ‘exit-code’.
Mai 20 19:17:03 srvHome01 systemd[1]: openhab2.service: Start request repeated too quickly.
Mai 20 19:17:03 srvHome01 systemd[1]: Failed to start The openHAB 2 Home Automation Bus Solution.
– Subject: Unit openhab2.service has failed
– Defined-By: systemd
– Support: h t t p s :// w w w - debian - org/support

– Unit openhab2.service has failed.

– The result is failed.
Mai 20 19:17:03 srvHome01 systemd[1]: openhab2.service: Failed with result ‘exit-code’.
lines 1679-1738/1738 (END)

These instructions that you followed are for a manual installation

I suggest that you follow the apt-get installation method: https://docs.openhab.org/installation/linux.html#package-repository-installation
(in the apt-get case, the openhab2.service file is created for you)

Also: How to use code fences

(and: it’s better to open up a new thread since this one is marked as solved)

hmmm… permissions maybe?

Hi Stephen, as @Dim mentioned the instructions for making your own service file are for the manual installations. Since you’ve installed openHAB via apt, this is done for you.

The file you created at /lib/systemd/system/openhab2.service is overriding the provided file: /usr/lib/systemd/system/openhab2.service. This makes the system think that everything is located in /usr/share/openhab2.

To get back on track delete your service file as follows:

sudo systemctl disable openhab2
sudo rm -f /lib/systemd/system/openhab2.service
sudo systemctl daemon-reload
sudo systemctl enable openhab2
sudo systemctl start openhab2

THX

I did

root@srvHome01:/# systemctl disable openhab2
Synchronizing state of openhab2.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install disable openhab2
root@srvHome01:/# rm -f /lib/systemd/system/openhab2.service
root@srvHome01:/# daemon-reload
bash: daemon-reload: Kommando nicht gefunden.
root@srvHome01:/# systemctl daemon-reload
root@srvHome01:/# systemctl enable openhab2
Synchronizing state of openhab2.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable openhab2
Created symlink /etc/systemd/system/multi-user.target.wants/openhab2.service → /usr/lib/systemd/system/openhab2.service.
root@srvHome01:/# systemctl start openhab2
root@srvHome01:/# systemctl status openhab2.service
● 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-20 19:44:03 CEST; 29s ago
Docs: http://docs.openhab.org
https://community.openhab.org
Main PID: 4932 (java)
Tasks: 149 (limit: 4915)
CGroup: /system.slice/openhab2.service
└─4932 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab.runtime=/usr/share/openhab2/runt

Mai 20 19:44:03 srvHome01 systemd[1]: Started openHAB 2 - empowering the smart home.

And it seems to run
But rus it as a service now?

…can you move it in a new thead?

Yes, it will stop and start automatically when you restart the machine.

I can’t but there’s no need, the service has started now so if you run into any more problems, it’s best to start a new thread when you need to.

OK Thanks for your help

Thank you!
For me using snapshot 2.4 this combination of the solutions above still solved the problem:

  • change the false pathways in file /lib/systemd/system/openhab2.service as suggested by @m3ld0n
  • remove the service file in other location as described by @Benjy on May 20th
  • create directories: /usr/share/openhab2/userdata, /usr/share/openhab2/userdata/tmp, /usr/share/openhab2/userdata/etc as described by @Robin_Keith June '17
  • check openhab:openhab access to folders using openhab-cli info ( as suggested here )
  • run sudo openhab-cli clean-cache as I found here