[SOLVED] Starting OH2/karaf on Fedora 30 fails due to permission issue

Hello All,

I am investigating using openHAB for my PHD thesis instead of a half-baken and overly time-consuming custom software.
My plan is to use it for potentially complex PID regulation system, involving several gas sensors and several actuators. I am trying to understand, if I can fit it to my needs.

I just installed openhab and already got a problem starting it up.

  • Platform information:
    • Hardware: x86_64
    • OS: Fedora 30
    • Java Runtime Environment: openjdk 12 from fedora
    • openHAB version: 2.4.0 stable
  • Issue of the topic:
    After installation via repo & package manager, ensuring correct group and rebooting, starting up openhab fails:
 sudo systemctl status openhab2.service
● openhab2.service - openHAB 2 - empowering the smart home
   Loaded: loaded (/usr/lib/systemd/system/openhab2.service; disabled; vendor preset: disabled)
   Active: activating (auto-restart) (Result: exit-code) since Wed 2019-08-28 13:01:02 CEST; 1s ago
     Docs: https://www.openhab.org/docs/
           https://community.openhab.org
  Process: 23277 ExecStart=/usr/share/openhab2/runtime/bin/karaf $OPENHAB_STARTMODE (code=exited, status=255/EXCEPTION)
 Main PID: 23277 (code=exited, status=255/EXCEPTION)

When manually starting, I get:

[leigva@localhost ~]$ /usr/share/openhab2/runtime/bin/karaf daemon
java.io.FileNotFoundException: /var/lib/openhab2/tmp/karaf.pid (Permission denied)
	at java.base/java.io.FileOutputStream.open0(Native Method)
	at java.base/java.io.FileOutputStream.open(FileOutputStream.java:292)
	at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:235)
	at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:124)
	at org.apache.karaf.main.InstanceHelper.writePid(InstanceHelper.java:126)
	at org.apache.karaf.main.Main.launch(Main.java:243)
	at org.apache.karaf.main.Main.main(Main.java:178)
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:178)
Caused by: java.io.FileNotFoundException: /var/log/openhab2/openhab.log (Permission denied)
	at java.base/java.io.FileOutputStream.open0(Native Method)
	at java.base/java.io.FileOutputStream.open(FileOutputStream.java:292)
	at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:235)
	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 2019-08-28 13:03:22.018 -----------------------------------------------
eclipse.buildId=unknown
java.version=12.0.2
java.vendor=N/A
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=de_DE

!ENTRY org.eclipse.osgi 4 0 2019-08-28 13:03:22.031
!MESSAGE Error reading configuration: /var/lib/openhab2/cache/org.eclipse.osgi/.manager/.fileTableLock (Permission denied)
!STACK 0
java.io.FileNotFoundException: /var/lib/openhab2/cache/org.eclipse.osgi/.manager/.fileTableLock (Permission denied)
	at java.base/java.io.RandomAccessFile.open0(Native Method)
	at java.base/java.io.RandomAccessFile.open(RandomAccessFile.java:347)
	at java.base/java.io.RandomAccessFile.<init>(RandomAccessFile.java:261)
	at java.base/java.io.RandomAccessFile.<init>(RandomAccessFile.java:216)
	at org.eclipse.osgi.internal.location.Locker_JavaNio.lock(Locker_JavaNio.java:36)
	at org.eclipse.osgi.storagemanager.StorageManager.lock(StorageManager.java:388)
	at org.eclipse.osgi.storagemanager.StorageManager.open(StorageManager.java:701)
	at org.eclipse.osgi.storage.Storage.getChildStorageManager(Storage.java:1776)
	at org.eclipse.osgi.storage.Storage.getInfoInputStream(Storage.java:1793)
	at org.eclipse.osgi.storage.Storage.<init>(Storage.java:132)
	at org.eclipse.osgi.storage.Storage.createStorage(Storage.java:85)
	at org.eclipse.osgi.internal.framework.EquinoxContainer.<init>(EquinoxContainer.java:68)
	at org.eclipse.osgi.launch.Equinox.<init>(Equinox.java:31)
	at org.eclipse.osgi.launch.EquinoxFactory.newFramework(EquinoxFactory.java:24)
	at org.apache.karaf.main.Main.launch(Main.java:256)
	at org.apache.karaf.main.Main.main(Main.java:178)

although:

$ groups openhab 
openhab : openhab tty dialout

$ls -l /usr/share/openhab2/runtime/bin/karaf 
-rwxr-xr-x. 1 openhab openhab 11846 17. Dez 2018  /usr/share/openhab2/runtime/bin/karaf

ls -l /var/lib/openhab2/tmp/karaf.pid 
-rw-r--r--. 1 openhab openhab 5 28. Aug 13:05 /var/lib/openhab2/tmp/karaf.pid

ls -l /var/log/openhab2/openhab.log
-rw-r--r--. 1 openhab openhab 1372766 28. Aug 13:04 /var/log/openhab2/openhab.log

$ sestatus 
....
Current mode:                   permissive

So, the binary runs as openhab user/group and the files it complains not having access to, are all set open to openhab. Disabling Selinux didn’t help either. Here is what happens when running with sudo:

$ sudo /usr/share/openhab2/runtime/bin/karaf daemon
KARAF_ETC is not valid: /usr/share/openhab2/userdata/etc

Any help would be appreciated!

Best,
Ingvar

Make sure you are using the recommended java version:

Thanks. Working now with zulu.

1 Like

You would do well in life if you research and read the documentation before blindly installing software or trying other new things.

What makes you think I blindly installed it? I barely overlooked that part of the docs.
If you have anything constructive to say, besides RTFM, I’d appreciate any insights.

A cursory research of OpenHAB and how to install it shows it currently requires Java 8.That somehow got missed.

I read about something similar in another thread. Check this post out

I will provide a word of caution. This sounds a whole lot like an industrial system you want to implement and/or emulate. OH is, IMHO, not suitable for such applications because:

  • it is not a real time system, there is no guarantee of timeliness of reaction to an event
  • it is multithreaded which becomes a huge problem when you need a system that is determinant
  • there is no guarantee of order of processing; if two events occur really close together they may be processed out of order
  • there is no concept of a transaction and if you try to make something that looks like a transaction using Rules you run a risk of breaking all of your Rules.

I just want you to be aware of these limitations before you get too far down the path and discover OH is not suitable for your task.

1 Like

Or one may even get dropped and not executed.

Thank you Rich Koshak for your constructive and honest answer. For the time being, I am working on a prototype which could live with relaxed guarantees, and a few missed measurements or occasional delays. But I do need, let’s call it, eventual reliability for safety reasons and not all requirements can be foreseen and of course it’s best to choose the right tool already now.
Transactions would be nice for safety, but in distributed systems there are hard to get in any way and I’m not sure I can really avoid distribution.
OH solves a lot of my problems and seems to be based on a robust foundation, and my own software development consumes a lot of time.

Thanks

I believe the Java license restricts its usage to non-critical situations. At least it used to.OH is based on Java.

Can you or somebody who knows source of such restriction can point where it comes from?

There are various situations where Java is used, more over it is used for some SCADA systems, some BMS. Both commercial and free. Sure it is not a thing for hard realtime where you control robot arm, yet for switching a valve a millisecond delay doesn’t change much. Safety systems work with short circuits in autonomous way so they react for life safety hazards with no human nor SCADA interaction.

Coming down to multithreading, loose of messages or missing the window for reading something - many of poll basses sensors have its own averaging and updating cycle (ie. 250 ms). Believe me - you can poll it several times before value changes even with Java.
PID controllers have lots of implementations in multiple scenarios yet for adjusting a heating/cooling circuit valve you can survive without a full blown realtime PLC simply because time of reaction for an average valve (most likely) is longer than a calculation cycle of a controller. I remember @george.erhan wrote a PID binding a while ago, and if he did it I’m sure he did it for a reason. :slight_smile:

Some applications will be just fine with imperfect hardware having imperfect software hosted by imperfect execution runtime, yet it will make somebody’s imperfect control system a little bit better or accurate. Tenants have a much more serious troubles in buildings which they do actually notice. A 0,01 ms delay in adjusting a heating circuit is below threshold anyone could possibly spot.

Cheers, Ɓukasz

Here is a quote from Oracle’s Java Binary Code license. The original license language was stronger.

it is not developed or intended for use in any inherently dangerous applications, including applications that may create a risk of personal injury. If you use the Software in dangerous applications, then you shall be responsible to take all appropriate fail-safe, backup, redundancy, and other measures to ensure its safe use. Oracle disclaims any express or implied warranty of fitness for such uses.

See https://www.oracle.com/downloads/licenses/binary-code-license.html

Thanks for answer Bruce. Might I differentiate that’s Oracle statement for their Java distribution/build. Given American way of suing anyone for anything, such disclaimer is not a surprise.
None of these apply to openjdk which is licensed under GNU GPL 2 with classpath exception: https://openjdk.java.net/legal/gplv2+ce.html

If you give next time such a note, please indicate it comes from Oracle licensing statements and apply to their version of Java runtime. It does not apply to openjdk and Azul, Amazon Corretto and programming language as general. Be aware that Azul and openjdk which are used with openhabian does not have these “strings attached”. In fact Azul has a product called Zing dedicated to financial markets and offer solution for predictable execution time.

1 Like