OpenHab UI not available after reboot - Java issues

Hey openhab community,

I am in the middle of re-setting-up my openhab 3 on a raspi 3 due to move to a new house.

Yesterday I restarted my openHAB instance and realized, that the UI is no longer available. However I can access the server via ssh.

I already did a few basic steps such as “clean-cache” and “fix permissions”. But the problem still persists.

I checked the status of openhab service and came across a few java errors mentioned in relation to karat console. So I went to /usr/share/openhab and ran bash star_debug.sh.

Here are the results:

openhabian@openhabian:/usr/share/openhab $ bash start_debug.sh
Launching the openHAB runtime...
Listening for transport dt_socket at address: 5005
java.io.FileNotFoundException: /var/lib/openhab/tmp/karaf.pid (Keine Berechtigung)
        at java.base/java.io.FileOutputStream.open0(Native Method)
        at java.base/java.io.FileOutputStream.open(FileOutputStream.java:298)
        at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:237)
        at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:126)
        at org.apache.karaf.main.InstanceHelper.writePid(InstanceHelper.java:126)
        at org.apache.karaf.main.Main.launch(Main.java:276)
        at org.apache.karaf.main.Main.main(Main.java:183)
java.lang.RuntimeException: /var/log/openhab/openhab.log (Keine Berechtigung)
        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:277)
        at org.apache.karaf.main.Main.main(Main.java:183)
Caused by: java.io.FileNotFoundException: /var/log/openhab/openhab.log (Keine Berechtigung)
        at java.base/java.io.FileOutputStream.open0(Native Method)
        at java.base/java.io.FileOutputStream.open(FileOutputStream.java:298)
        at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:237)
        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 2022-03-24 07:28:04.281 -----------------------------------------------
eclipse.buildId=unknown
java.version=11.0.14
java.vendor=Raspbian
BootLoader constants: OS=linux, ARCH=arm, WS=gtk, NL=de_DE

!ENTRY org.eclipse.osgi 4 0 2022-03-24 07:28:04.619
!MESSAGE Error reading configuration: /var/lib/openhab/cache/org.eclipse.osgi/.manager/.fileTableLock (Keine Berechtigung)
!STACK 0
java.io.FileNotFoundException: /var/lib/openhab/cache/org.eclipse.osgi/.manager/.fileTableLock (Keine Berechtigung)
        at java.base/java.io.RandomAccessFile.open0(Native Method)
        at java.base/java.io.RandomAccessFile.open(RandomAccessFile.java:345)
        at java.base/java.io.RandomAccessFile.<init>(RandomAccessFile.java:259)
        at java.base/java.io.RandomAccessFile.<init>(RandomAccessFile.java:214)
        at org.eclipse.osgi.internal.location.Locker_JavaNio.lock(Locker_JavaNio.java:40)
        at org.eclipse.osgi.storagemanager.StorageManager.lock(StorageManager.java:403)
        at org.eclipse.osgi.storagemanager.StorageManager.open(StorageManager.java:716)
        at org.eclipse.osgi.storage.Storage.getChildStorageManager(Storage.java:2266)
        at org.eclipse.osgi.storage.Storage.getInfoInputStream(Storage.java:2283)
        at org.eclipse.osgi.storage.Storage.<init>(Storage.java:252)
        at org.eclipse.osgi.storage.Storage.createStorage(Storage.java:180)
        at org.eclipse.osgi.internal.framework.EquinoxContainer.<init>(EquinoxContainer.java:108)
        at org.eclipse.osgi.launch.Equinox.<init>(Equinox.java:53)
        at org.eclipse.osgi.launch.EquinoxFactory.newFramework(EquinoxFactory.java:35)
        at org.eclipse.osgi.launch.EquinoxFactory.newFramework(EquinoxFactory.java:30)
        at org.apache.karaf.main.Main.launch(Main.java:289)
        at org.apache.karaf.main.Main.main(Main.java:183)

I am having troubles, as I am not an expert in java and also all openhab related stuff I learned “on the fly”. Hence I would appreciate any help to solve my issue and avoid any re-setup.

Thanks upfront to this awesome community.

Could you do

ls -ld /var/log/openhab /var/log/openhab/openhab.log /var/lib/openhab/tmp/karaf.pid /var/lib/openhab/cache/org.eclipse.osgi/.manager/.fileTableLock

according to the error message ( no permision / keine Berechtigung ) I assume that at least the last three are owned by root and not the user openhab:openhab.

Please run the above command to check this ‘theory’ then run fix permissions and afterwards the above command again to check that permissions are fixed.

Hi @Wolfgang_S,

thanks a lot for the quick reply. I ran a bit further down the road on this and came across the log folder being assigned to openhab:opehabian - which is in my view wrong. This should be openhab:openhab, correct?

So I ran openhab-cli reset-ownership as the fix permission in openhabian-config did not work out previously.

Currently the result of your request looks as follows:

-rw-r--r-- 1 openhab openhab    0 24. Mär 07:21 /var/lib/openhab/cache/org.eclipse.osgi/.manager/.fileTableLock
-rw-r--r-- 1 openhab openhab    4 24. Mär 07:44 /var/lib/openhab/tmp/karaf.pid
drwxrwxr-x 1 openhab openhab 4096 24. Mär 07:38 /var/log/openhab
-rw-r--r-- 1 openhab openhab    0 24. Mär 07:21 /var/log/openhab/openhab.log

To me, this looks okay now. Shall I give it a try and restart my RaspberryPi?

Adding to that, I now see, that the UI is back up. So it seems that the permission to the log file/folder were causing this issue.

Do I need to restart or do any further checks to make sure it is properly running?

openhab:openhabian shouldn’t have been the root cause. The owner openhab should be ok as the owner then has write permission. Permissions now are fine. Before the files were most probably owned by root ( can’t see that any longer as the before ls command was not done ) and thus user openhab was not able to write to that files.
Although it is not required you can do a full restart of the system then you are sure that everything works as expected.

Okay, I did that. But now it seems like all my discoveries have been removed. The log shows various errors.

z.B.

2022-03-24 07:53:31.158 [INFO ] [openhab.event.InboxRemovedEvent     ] - Discovery Result with UID 'hue:group:ecb5fa1ee339:0' has been removed.
2022-03-24 08:05:34.828 [WARN ] [.transport.servlet.ServletController] - Can't find the request for http://192.168.178.46:8080/rest/addons/services's Observer 
2022-03-24 08:05:58.903 [ERROR] [core.karaf.internal.FeatureInstaller] - Failed installing 'openhab-binding-hue, openhab-binding-deconz, openhab-misc-openhabcloud, openhab-binding-network, openhab-binding-amazonechocontrol, openhab-binding-sonos, openhab-ui-habpanel, openhab-binding-miio, openhab-binding-nuki, openhab-persistence-rrd4j, openhab-binding-netatmo, openhab-ui-basic, openhab-binding-ntp, openhab-binding-openweathermap, openhab-binding-systeminfo': null

But now, everything is slowly starting to come back. Very strange. I get another regular error:

2022-03-24 08:18:07.158 [INFO ] [control.internal.WebSocketConnection] - Web Socket close 1005. Reason: null

Any thoughts on the above errors, the behavior that all disappeared and now is coming back or the socket error?