OpenHab2 do not start as service anymore

Hi all,
I have this issue and I don’t know how to fix, and so I’m asking your help.
Today I installed AmazonDash binding and did procedure described at this page:
http://docs.openhab.org/addons/bindings/amazondashbutton/readme.html

I installed libpcap-dev and then run command to enable capture:
sudo setcap ‘cap_net_raw,cap_net_admin=+eip cap_net_bind_service=+ep’ realpath /usr/bin/java

I don’t know if this is the root cause of my issue, because I do not reboot openhab since 2 weeks, but today it wont restart as service, and I have to run it from console with ./startup.sh and leave console open.

Running systemctl status, i got this:

root@OpenHab2:/usr/share/openhab2# systemctl enable openhab2
Synchronizing state for openhab2.service with sysvinit using update-rc.d...
Executing /usr/sbin/update-rc.d openhab2 defaults
Executing /usr/sbin/update-rc.d openhab2 enable
root@OpenHab2:/usr/share/openhab2# systemctl start openhab2
root@OpenHab2:/usr/share/openhab2# systemctl status openhab2
● openhab2.service - openHAB 2 - empowering the smart home
   Loaded: loaded (/usr/lib/systemd/system/openhab2.service; enabled)
   Active: failed (Result: start-limit) since Sat 2016-11-26 01:18:41 CET; 873ms ago
     Docs: http://docs.openhab.org
           https://community.openhab.org
  Process: 19602 ExecStop=/usr/share/openhab2/runtime/karaf/bin/stop (code=exited, status=127)
  Process: 19530 ExecStart=/usr/share/openhab2/start.sh server (code=exited, status=127)
 Main PID: 19530 (code=exited, status=127)

Nov 26 01:18:40 OpenHab2 systemd[1]: openhab2.service: control process exited, code=exited status=127
Nov 26 01:18:40 OpenHab2 systemd[1]: Unit openhab2.service entered failed state.
Nov 26 01:18:41 OpenHab2 systemd[1]: openhab2.service holdoff time over, scheduling restart.
Nov 26 01:18:41 OpenHab2 systemd[1]: Stopping openHAB 2 - empowering the smart home...
Nov 26 01:18:41 OpenHab2 systemd[1]: Starting openHAB 2 - empowering the smart home...
Nov 26 01:18:41 OpenHab2 systemd[1]: openhab2.service start request repeated too quickly, refusing to start.
Nov 26 01:18:41 OpenHab2 systemd[1]: Failed to start openHAB 2 - empowering the smart home.
Nov 26 01:18:41 OpenHab2 systemd[1]: Unit openhab2.service entered failed state.

Someone can help me?

Many Thanks

Marco

I did more investigation, in syslog i got this when i try to start OpenHab2 from systemctl:

Nov 26 03:11:53 OpenHab2 systemd[1]: Starting openHAB 2 - empowering the smart home...
Nov 26 03:11:53 OpenHab2 systemd[1]: Started openHAB 2 - empowering the smart home.
Nov 26 03:11:53 OpenHab2 start.sh[28957]: Launching the openHAB runtime...
Nov 26 03:11:53 OpenHab2 start.sh[28957]: /usr/share/openhab2/runtime/karaf/bin/karaf: 180: [: Illegal number:
Nov 26 03:11:53 OpenHab2 start.sh[28957]: /usr/share/openhab2/runtime/karaf/bin/karaf: 239: [: Illegal number:
Nov 26 03:11:53 OpenHab2 start.sh[28957]: /usr/share/openhab2/runtime/karaf/bin/karaf: 284: [: Illegal number:
Nov 26 03:11:53 OpenHab2 start.sh[28957]: /usr/bin/java: error while loading shared libraries: libjli.so: cannot open shared object file: No such file or directory
Nov 26 03:11:53 OpenHab2 systemd[1]: openhab2.service: main process exited, code=exited, status=127/n/a
Nov 26 03:11:53 OpenHab2 stop[29028]: /usr/share/openhab2/runtime/karaf/bin/stop: 180: [: Illegal number:
Nov 26 03:11:53 OpenHab2 stop[29028]: stop: Ignoring predefined value for KARAF_HOME
Nov 26 03:11:53 OpenHab2 stop[29028]: /usr/share/openhab2/runtime/karaf/bin/karaf: 180: [: Illegal number:
Nov 26 03:11:53 OpenHab2 stop[29028]: /usr/share/openhab2/runtime/karaf/bin/karaf: 239: [: Illegal number:
Nov 26 03:11:53 OpenHab2 stop[29028]: /usr/share/openhab2/runtime/karaf/bin/karaf: 284: [: Illegal number:
Nov 26 03:11:53 OpenHab2 stop[29028]: /opt/jdk/jdk1.8.0_102/bin/java: error while loading shared libraries: libjli.so: cannot open shared object file: No such file or directory
Nov 26 03:11:53 OpenHab2 systemd[1]: openhab2.service: control process exited, code=exited status=127
Nov 26 03:11:53 OpenHab2 systemd[1]: Unit openhab2.service entered failed state.
Nov 26 03:11:54 OpenHab2 systemd[1]: openhab2.service holdoff time over, scheduling restart.
Nov 26 03:11:54 OpenHab2 systemd[1]: Stopping openHAB 2 - empowering the smart home...
Nov 26 03:11:54 OpenHab2 systemd[1]: Starting openHAB 2 - empowering the smart home...
Nov 26 03:11:54 OpenHab2 systemd[1]: Started openHAB 2 - empowering the smart home.
Nov 26 03:11:54 OpenHab2 start.sh[29115]: Launching the openHAB runtime...
Nov 26 03:11:54 OpenHab2 start.sh[29115]: /usr/share/openhab2/runtime/karaf/bin/karaf: 180: [: Illegal number:
Nov 26 03:11:54 OpenHab2 start.sh[29115]: /usr/share/openhab2/runtime/karaf/bin/karaf: 239: [: Illegal number:
Nov 26 03:11:54 OpenHab2 start.sh[29115]: /usr/share/openhab2/runtime/karaf/bin/karaf: 284: [: Illegal number:
Nov 26 03:11:54 OpenHab2 start.sh[29115]: /usr/bin/java: error while loading shared libraries: libjli.so: cannot open shared object file: No such file or directory
Nov 26 03:11:54 OpenHab2 systemd[1]: openhab2.service: main process exited, code=exited, status=127/n/a
Nov 26 03:11:54 OpenHab2 stop[29186]: /usr/share/openhab2/runtime/karaf/bin/stop: 180: [: Illegal number:
Nov 26 03:11:54 OpenHab2 stop[29186]: stop: Ignoring predefined value for KARAF_HOME
Nov 26 03:11:54 OpenHab2 stop[29186]: /usr/share/openhab2/runtime/karaf/bin/karaf: 180: [: Illegal number:
Nov 26 03:11:54 OpenHab2 stop[29186]: /usr/share/openhab2/runtime/karaf/bin/karaf: 239: [: Illegal number:
Nov 26 03:11:54 OpenHab2 stop[29186]: /usr/share/openhab2/runtime/karaf/bin/karaf: 284: [: Illegal number:
Nov 26 03:11:54 OpenHab2 stop[29186]: /opt/jdk/jdk1.8.0_102/bin/java: error while loading shared libraries: libjli.so: cannot open shared object file: No such file or directory
Nov 26 03:11:54 OpenHab2 systemd[1]: openhab2.service: control process exited, code=exited status=127
Nov 26 03:11:54 OpenHab2 systemd[1]: Unit openhab2.service entered failed state.
Nov 26 03:11:54 OpenHab2 systemd[1]: openhab2.service holdoff time over, scheduling restart.
Nov 26 03:11:54 OpenHab2 systemd[1]: Stopping openHAB 2 - empowering the smart home...
Nov 26 03:11:54 OpenHab2 systemd[1]: Starting openHAB 2 - empowering the smart home...
Nov 26 03:11:54 OpenHab2 start.sh[29272]: Launching the openHAB runtime...
Nov 26 03:11:54 OpenHab2 systemd[1]: Started openHAB 2 - empowering the smart home.
Nov 26 03:11:54 OpenHab2 start.sh[29272]: /usr/share/openhab2/runtime/karaf/bin/karaf: 180: [: Illegal number:
Nov 26 03:11:54 OpenHab2 start.sh[29272]: /usr/share/openhab2/runtime/karaf/bin/karaf: 239: [: Illegal number:
Nov 26 03:11:54 OpenHab2 start.sh[29272]: /usr/share/openhab2/runtime/karaf/bin/karaf: 284: [: Illegal number:
Nov 26 03:11:54 OpenHab2 start.sh[29272]: /usr/bin/java: error while loading shared libraries: libjli.so: cannot open shared object file: No such file or directory
Nov 26 03:11:54 OpenHab2 systemd[1]: openhab2.service: main process exited, code=exited, status=127/n/a
Nov 26 03:11:54 OpenHab2 stop[29343]: /usr/share/openhab2/runtime/karaf/bin/stop: 180: [: Illegal number:
Nov 26 03:11:54 OpenHab2 stop[29343]: stop: Ignoring predefined value for KARAF_HOME
Nov 26 03:11:54 OpenHab2 stop[29343]: /usr/share/openhab2/runtime/karaf/bin/karaf: 180: [: Illegal number:
Nov 26 03:11:54 OpenHab2 stop[29343]: /usr/share/openhab2/runtime/karaf/bin/karaf: 239: [: Illegal number:
Nov 26 03:11:54 OpenHab2 stop[29343]: /usr/share/openhab2/runtime/karaf/bin/karaf: 284: [: Illegal number:
Nov 26 03:11:54 OpenHab2 systemd[1]: openhab2.service: control process exited, code=exited status=127
Nov 26 03:11:54 OpenHab2 systemd[1]: Unit openhab2.service entered failed state.
Nov 26 03:11:54 OpenHab2 stop[29343]: /opt/jdk/jdk1.8.0_102/bin/java: error while loading shared libraries: libjli.so: cannot open shared object file: No such file or directory
Nov 26 03:11:54 OpenHab2 systemd[1]: openhab2.service holdoff time over, scheduling restart.
Nov 26 03:11:54 OpenHab2 systemd[1]: Stopping openHAB 2 - empowering the smart home...
Nov 26 03:11:54 OpenHab2 systemd[1]: Starting openHAB 2 - empowering the smart home...
Nov 26 03:11:54 OpenHab2 systemd[1]: Started openHAB 2 - empowering the smart home.
Nov 26 03:11:54 OpenHab2 start.sh[29429]: Launching the openHAB runtime...
Nov 26 03:11:54 OpenHab2 start.sh[29429]: /usr/share/openhab2/runtime/karaf/bin/karaf: 180: [: Illegal number:
Nov 26 03:11:54 OpenHab2 start.sh[29429]: /usr/share/openhab2/runtime/karaf/bin/karaf: 239: [: Illegal number:
Nov 26 03:11:54 OpenHab2 start.sh[29429]: /usr/share/openhab2/runtime/karaf/bin/karaf: 284: [: Illegal number:
Nov 26 03:11:54 OpenHab2 start.sh[29429]: /usr/bin/java: error while loading shared libraries: libjli.so: cannot open shared object file: No such file or directory
Nov 26 03:11:54 OpenHab2 systemd[1]: openhab2.service: main process exited, code=exited, status=127/n/a
Nov 26 03:11:54 OpenHab2 stop[29501]: /usr/share/openhab2/runtime/karaf/bin/stop: 180: [: Illegal number:
Nov 26 03:11:54 OpenHab2 stop[29501]: stop: Ignoring predefined value for KARAF_HOME
Nov 26 03:11:54 OpenHab2 stop[29501]: /usr/share/openhab2/runtime/karaf/bin/karaf: 180: [: Illegal number:
Nov 26 03:11:54 OpenHab2 stop[29501]: /usr/share/openhab2/runtime/karaf/bin/karaf: 239: [: Illegal number:
Nov 26 03:11:54 OpenHab2 stop[29501]: /usr/share/openhab2/runtime/karaf/bin/karaf: 284: [: Illegal number:
Nov 26 03:11:54 OpenHab2 stop[29501]: /opt/jdk/jdk1.8.0_102/bin/java: error while loading shared libraries: libjli.so: cannot open shared object file: No such file or directory
Nov 26 03:11:54 OpenHab2 systemd[1]: openhab2.service: control process exited, code=exited status=127
Nov 26 03:11:54 OpenHab2 systemd[1]: Unit openhab2.service entered failed state.
Nov 26 03:11:54 OpenHab2 systemd[1]: openhab2.service holdoff time over, scheduling restart.
Nov 26 03:11:54 OpenHab2 systemd[1]: Stopping openHAB 2 - empowering the smart home...
Nov 26 03:11:54 OpenHab2 systemd[1]: Starting openHAB 2 - empowering the smart home...
Nov 26 03:11:54 OpenHab2 systemd[1]: Started openHAB 2 - empowering the smart home.
Nov 26 03:11:54 OpenHab2 start.sh[29587]: Launching the openHAB runtime...
Nov 26 03:11:54 OpenHab2 start.sh[29587]: /usr/share/openhab2/runtime/karaf/bin/karaf: 180: [: Illegal number:
Nov 26 03:11:54 OpenHab2 start.sh[29587]: /usr/share/openhab2/runtime/karaf/bin/karaf: 239: [: Illegal number:
Nov 26 03:11:54 OpenHab2 start.sh[29587]: /usr/share/openhab2/runtime/karaf/bin/karaf: 284: [: Illegal number:
Nov 26 03:11:54 OpenHab2 start.sh[29587]: /usr/bin/java: error while loading shared libraries: libjli.so: cannot open shared object file: No such file or directory
Nov 26 03:11:54 OpenHab2 systemd[1]: openhab2.service: main process exited, code=exited, status=127/n/a
Nov 26 03:11:54 OpenHab2 stop[29658]: /usr/share/openhab2/runtime/karaf/bin/stop: 180: [: Illegal number:
Nov 26 03:11:54 OpenHab2 stop[29658]: stop: Ignoring predefined value for KARAF_HOME
Nov 26 03:11:54 OpenHab2 stop[29658]: /usr/share/openhab2/runtime/karaf/bin/karaf: 180: [: Illegal number:
Nov 26 03:11:54 OpenHab2 stop[29658]: /usr/share/openhab2/runtime/karaf/bin/karaf: 239: [: Illegal number:
Nov 26 03:11:54 OpenHab2 stop[29658]: /usr/share/openhab2/runtime/karaf/bin/karaf: 284: [: Illegal number:
Nov 26 03:11:54 OpenHab2 stop[29658]: /opt/jdk/jdk1.8.0_102/bin/java: error while loading shared libraries: libjli.so: cannot open shared object file: No such file or directory
Nov 26 03:11:54 OpenHab2 systemd[1]: openhab2.service: control process exited, code=exited status=127
Nov 26 03:11:54 OpenHab2 systemd[1]: Unit openhab2.service entered failed state.
Nov 26 03:11:55 OpenHab2 systemd[1]: openhab2.service holdoff time over, scheduling restart.
Nov 26 03:11:55 OpenHab2 systemd[1]: Stopping openHAB 2 - empowering the smart home...
Nov 26 03:11:55 OpenHab2 systemd[1]: Starting openHAB 2 - empowering the smart home...
Nov 26 03:11:55 OpenHab2 systemd[1]: openhab2.service start request repeated too quickly, refusing to start.
Nov 26 03:11:55 OpenHab2 systemd[1]: Failed to start openHAB 2 - empowering the smart home.
Nov 26 03:11:55 OpenHab2 systemd[1]: Unit openhab2.service entered failed state.

I checked on my system, and I have the metioned library in:
./opt/jdk/jdk1.8.0_102/jre/lib/amd64/jli/libjli.so
./opt/jdk/jdk1.8.0_102/lib/amd64/jli/libjli.so

I checked that permission are the samo on all other java files in this directory.
In addition looking at openhab running in console, i got this messages:

even is OpenHab seems to work fine.

Marco

Finally I found issue into setcap comman ran for enable Amazon Dash.
Removing setcap with this command:
setcap -r /opt/jdk/jdk1.8.0_102/bin/java

now openhab start, but Amazon Dash binding do not work anymore.

Is there a way to run Amazon Dash Binding and start openhab as a service?

Thanks a lot.

Marco

For me it worked without any problems with this setcap command:

sudo setcap cap_net_raw,cap_net_admin=eip `realpath /usr/bin/java`

Hi,
I installed openHab2 from repository, so it run as openhab user and non root.
I tried to add setcap permission as root and logged as openhab user, but in both case, openhab do not start as a service.

Same here. Although I’m using a manually installed openHAB2 online version, but runs under user openhab.

I tried again now,
if i run setcap, openhab do no stars as a service and got same errors i posted before.

I have to find another way to use amazon dash without using the binding.

Marco

Have same problem with openhab2
Using

sudo setcap -r `realpath /usr/bin/java

service openhab2 will start.
Using

sudo setcap cap_net_raw,cap_net_admin=eip `realpath /usr/bin/java`

service openhab2 will not start, error is

openhab2 karaf[12664]: /usr/bin/java: error while loading shared libraries: libjli.so: cannot open shared object file: No such file or directory

running openhab2 on raspberry pi3 (raspian)

Tested the following:
logged in as non root user

removed all capabilities by

sudo setcap -r $(realpath /usr/bin/java)

Java is working for non root user:

pi@openhab2:~ $ java -version
java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) Client VM (build 25.111-b14, mixed mode)

settilng capabilities to java:

pi@openhab2:~ $ sudo setcap cap_net_raw,cap_net_admin=eip $(realpath /usr/bin/java)
pi@openhab2:~ $ java -version
java: error while loading shared libraries: libjli.so: cannot open shared object file: No such file or directory
pi@openhab2:~ $ sudo java -version
java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) Client VM (build 25.111-b14, mixed mode)

Java is working only for root user.
Again removin capabilities:

pi@openhab2:~ $ sudo setcap -r $(realpath /usr/bin/java)
pi@openhab2:~ $ java -version
java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) Client VM (build 25.111-b14, mixed mode)

Java is working for non root user

Any ideas how to solve the problem?

May by the only sollution is to grant sudo privileges to openhab user? In this case there is no need to setcap to get the Amazon dash button binding running.