Errors after installing from the repository (rpm)

  • Platform information:

    • Hardware: VMware 1 CPU/i386/512k/unlimited storage
    • OS: CentOS 6.9 32bit
    • Java Runtime Environment: Java™ SE Runtime Environment (build 1.8.0_151-b12)
    • openHAB version: openhab2-2.3.0.20171222170803-1.noarch
  • Issue of the topic: Was running v2 out of /opt/openhab2, deleted. Installed from repository.

    (root@ha1srvp01:/usr/share/openhab2)$ ./start.sh
    Launching the openHAB runtime…
    mkdir: cannot create directory `/usr/share/openhab2/userdata/tmp’: No such file or directory
    KARAF_BASE is not valid: /usr/share/openhab2/userdata

The install did not create /usr/share/openhab2/userdata

Is there a problem with the rpm builds?

EDIT: Hmm, looks like it’s worse than that.

(root@ha1srvp01:/usr/share/openhab2)$ mkdir userdata
(root@ha1srvp01:/usr/share/openhab2)$ chown openhab:openhab userdata
(root@ha1srvp01:/usr/share/openhab2)$ ./start.sh
Launching the openHAB runtime...
KARAF_ETC is not valid: /usr/share/openhab2/userdata/etc
(root@ha1srvp01:/usr/share/openhab2/userdata)$ ln -s /usr/share/openhab2/runtime/etc etc
(root@ha1srvp01:/usr/share/openhab2/userdata)$ cd ..
(root@ha1srvp01:/usr/share/openhab2)$ ./start_debug.sh
Launching the openHAB runtime...
Listening for transport dt_socket at address: 5005
null
Error occurred shutting down framework: java.lang.NumberFormatException: null
java.lang.NumberFormatException: null
        at java.lang.Integer.parseInt(Unknown Source)
        at java.lang.Integer.parseInt(Unknown Source)
        at org.apache.karaf.main.ConfigProperties.<init>(ConfigProperties.java:214)
        at org.apache.karaf.main.Main.updateInstancePidAfterShutdown(Main.java:228)
        at org.apache.karaf.main.Main.main(Main.java:193)

It seems to be pretty messed up.

The packaged repositories use separated directories. So it’s a slightly different way of starting openHAB.

To open an instance of openhab in the terminal, use:

openhab-cli start

I’d recommend reading this section in the docs for more usage info.

1 Like

Thanks. I had eventually figured out the openhab-cli shell.

Unfortunately, service openhab2 start does not start it, which is the real goal. It also dosen’t log anything, so I have no idea what it’s unhappy about.

Cents 6.9 is an sysvinit driven OS.

sudo /etc/init.d/openhab2 start
sudo /etc/init.d/openhab2 status

sudo update-rc.d openhab2 defaults

Should at least bring up some information for you.

Yea, those commands are equivalent to

service openhab2 start
service openhab2 status

Under the covers it tries to spawn /usr/share/openhab2/runtime/bin/start, waits to see the process start up, creates the /var/run/openhab2.pid, and then returns OK.

The problem is the process runs into some issue on startup and then silently quits. It’s easier to debug when it fails on manual start too, but in this case it starts normally.

So,

runuser root /usr/share/openhab2/runtime/bin/start

starts normally,

runuser openhab /usr/share/openhab2/runtime/bin/start

just quits.

I think I have sorted it all out and I would sum this whole thing up as

It will work just fine if you don’t break it first.

Important note, don’t start it as root! … or any other user for that matter. Files will get created with root as the owner and then startup will fail when the openhab user can’t access things.

Also, adding

KARAF_REDIRECT=/tmp/karaf.out
export KARAF_REDIRECT

to the environment will cause the process to go to a file instead of /dev/null which is very helpful at times like these:

Unable to update instance pid: /var/lib/openhab2/tmp/instances/instance.properties (Permission denied)
java.lang.RuntimeException: /var/log/openhab2/openhab.log (Permission denied)
        at org.apache.karaf.main.util.BootstrapLogManager.getDefaultHandlerInternal(BootstrapLogManager.java:102)
        at org.apache.karaf.main.util.BootstrapLogManager.getDefaultHandlersInternal(BootstrapLogManager.java:137)
        at org.apache.karaf.main.util.BootstrapLogManager.getDefaultHandlers(BootstrapLogManager.java:70)
        at org.apache.karaf.main.util.BootstrapLogManager.configureLogger(BootstrapLogManager.java:75)
        at org.apache.karaf.main.Main.launch(Main.java:244)
        at org.apache.karaf.main.Main.main(Main.java:179)
Caused by: java.io.FileNotFoundException: /var/log/openhab2/openhab.log (Permission denied)
        at java.io.FileOutputStream.open0(Native Method)
        at java.io.FileOutputStream.open(Unknown Source)
        at java.io.FileOutputStream.<init>(Unknown Source)
        at org.apache.karaf.main.util.BootstrapLogManager$SimpleFileHandler.open(BootstrapLogManager.java:193)
        at org.apache.karaf.main.util.BootstrapLogManager$SimpleFileHandler.<init>(BootstrapLogManager.java:182)
        at org.apache.karaf.main.util.BootstrapLogManager.getDefaultHandlerInternal(BootstrapLogManager.java:100)
        ... 5 more
!SESSION 2017-12-26 11:43:25.866 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.8.0_151
java.vendor=Oracle Corporation
BootLoader constants: OS=linux, ARCH=x86, WS=gtk, NL=en_US

Hi @tlum, glad you got it sorted. That’s very handy to know, we should probably add some catch for the user or group permissions on the Linux start up end.

Admittedly, I haven’t worked on the init.d files for a while but if you find any more things that could do with some improvements it would be really helpful to put them on the openhab/openhab-linuxpkg Github repo as issues.

There’s actually an env var, KARAF_NOROOT, that if defined, will cause the karaf wrapper to die if you try to run as root. I’m not sure how much good that would do though, since any user who creates objects that the openhab user can’t access would run into the same problem.

What really killed me was the log directory got created by root so the openhab user could not even log all the access errors it was getting. Adding at least that to the install package might insure that a fool like me can’t break the logging as easily.

thanks. it’s work!