Running into a couple of issues with my openHAB, I realised this a few days ago when my classic ui was working one minute and not the next. I am running openHAB 2.4.0-1. Look at a few posts saying to clean the cache so I did that and the interefaces worked but no connection to items so I have run a status check and this is what it brings up.
`[19:45:49] openhabian@openHABianPi:~$ sudo systemctl status openhab2.service
[sudo] password for openhabian:
● openhab2.service - openHAB 2 - empowering the smart home
Loaded: loaded (/usr/lib/systemd/system/openhab2.service; enabled; vendor preset:
Active: activating (auto-restart) (Result: exit-code) since Fri 2018-12-21 19:45:5
Docs: https://www.openhab.org/docs/
https://community.openhab.org
Process: 27988 ExecStop=/usr/share/openhab2/runtime/bin/karaf stop (code=exited, st
Process: 27572 ExecStart=/usr/share/openhab2/runtime/bin/karaf $OPENHAB_STARTMODE (
Main PID: 27572 (code=exited, status=255)
Dec 21 19:45:52 openHABianPi systemd[1]: openhab2.service: Failed with result 'exit-c`
Sometimes it says openHAB has started but an error comes up with the Karaf and other times it either doesn’t start or stops shortly after. I don’t know how to access the logs to give anymore information. I’m using putty if anyone can tell me how to access and view the logs please.
Any advice to resolve this issue is much appreciated
OpenHAB has started but throwing up permission errors on the karaf?
● openhab2.service - openHAB 2 - empowering the smart home
Loaded: loaded (/usr/lib/systemd/system/openhab2.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2018-12-21 20:22:38 GMT; 2s ago
Docs: https://www.openhab.org/docs/ https://community.openhab.org
Process: 8216 ExecStop=/usr/share/openhab2/runtime/bin/karaf stop (code=exited, status=1/FAILURE)
Main PID: 8327 (java)
CGroup: /system.slice/openhab2.service
└─8327 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab.runtime=/usr/share/openhab2/runtime -Dopenhab.
Dec 21 20:22:38 openHABianPi systemd[1]: Started openHAB 2 - empowering the smart home.
Dec 21 20:22:40 openHABianPi karaf[8327]: java.io.FileNotFoundException: /var/lib/openhab2/tmp/karaf.pid (Permission denied)
Dec 21 20:22:40 openHABianPi karaf[8327]: at java.io.FileOutputStream.open0(Native Method)
Dec 21 20:22:40 openHABianPi karaf[8327]: at java.io.FileOutputStream.open(FileOutputStream.java:270)
Dec 21 20:22:40 openHABianPi karaf[8327]: at java.io.FileOutputStream.(FileOutputStream.java:213)
Dec 21 20:22:40 openHABianPi karaf[8327]: at java.io.FileOutputStream.(FileOutputStream.java:101)
Dec 21 20:22:40 openHABianPi karaf[8327]: at org.apache.karaf.main.InstanceHelper.writePid(InstanceHelper.java:126)
Dec 21 20:22:40 openHABianPi karaf[8327]: at org.apache.karaf.main.Main.launch(Main.java:243)
Dec 21 20:22:40 openHABianPi karaf[8327]: at org.apache.karaf.main.Main.main(Main.java:178)
how did you perform the cleaning of /var/lib/openhab2/cache & /var/lib/openhab2/tmp directories?
It seems that some specific method (on openHABian that I haven’t been able to identify until now) results in modified permissions after the cleaning of these 2 subdirs, and as a result, OH2 service (using username openhab) will not be able to write into them afterwards.
first check current permissions:
ls -al /var/lib/openhab2/cache /var/lib/openhab2/tmp
this is not a problem since these files have a read permission for all, so you are fine with that.
OH2 process (running as the openhab user) simply reads them (no need to write and/or execute).
The OH2 process needs to be able to write into other dirs (e.g. log, tmp, cache, jsondb, etc). Mainly in $OPENHAB_USERDATA (/var/lib/openhab2/) space.
How did you clear the tmp & cache in the first place and what permissions did you have on tmp & cache?
not exactly the same… I don’t see any permission denied errors.
what does openhab.log say?
try clearing tmp & cache again and make sure that the permissions are ok within /var/lib/openhab2/
I cleared it with the above guide first by using the clean command then after that did not work I deleted them with the second guide. They did have root root permissions until I changed them like you said. I will check log again now and check permissions
you mean: openhab-cli clean-cache ?
did you run it as root or as openhabian user?
I am trying to reproduce the steps because I have seen this problem several times but I can’t identify the exact steps that were taken.
what do you mean: “did not work” ? the dirs were not removed with openhab-cli clean-cache ?
which is the second guide ? (link to it plz)
Yes I used openhab-cli clean-cache,
No I mean the problem wasn’t resolved to intrude the second option. I used the sudo command at the start logged in as openhabian user.
The permissions are as follows
`[22:20:17] openhabian@openHABianPi:/$ ls -l /var/lib/openhab2/
total 16332
drwxrwxr-x+ 4 openhab openhab 4096 Dec 21 18:53 cache
drwxrwxr-x+ 5 openhab openhab 4096 Dec 21 18:53 config
-rw-rw-r-- 1 root root 7248681 Dec 21 17:58 dump-2018-12-21_175738-883.zip
-rw-rw-r-- 1 root root 9432921 Dec 21 18:56 dump-2018-12-21_185623-990.zip
drwxrwxr-x+ 3 openhab openhabian 12288 Dec 21 18:43 etc
drwxrwxr-x+ 3 openhab openhab 4096 Dec 21 17:41 jsondb
drwxrwxr-x+ 2 openhab openhab 4096 May 28 2018 openhabcloud
drwxrwxr-x+ 5 openhab openhabian 4096 May 28 2018 persistence
drwxrwxr-x+ 8 openhab openhab 4096 Dec 21 21:29 tmp
-rw-rw-r-- 1 openhab openhab 37 May 28 2018 uuid`
`[22:44:23] openhabian@openHABianPi:~$ tail -f /var/log/openhab2/openhab.log
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1317) ~[?:?]
at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:293) ~[?:?]
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203) ~[?:?]
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473) ~[?:?]
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1564) ~[?:?]
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201) ~[?:?]
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1219) ~[?:?]
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144) ~[?:?]
at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:80) ~[?:?]
... 15 more`
2018-12-21 23:02:52.408 [SEVERE] [org.apache.karaf.main.Main] - Could not launch fram
ework
java.lang.RuntimeException: Error initializing storage.
at org.eclipse.osgi.internal.framework.EquinoxContainer.(EquinoxContain
er.java:70)
at org.eclipse.osgi.launch.Equinox.(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)
Caused by: java.io.FileNotFoundException: /var/lib/openhab2/cache/org.eclipse.osgi/.m
anager/.fileTableLock (Permission denied)
at java.io.RandomAccessFile.open0(Native Method)
at java.io.RandomAccessFile.open(RandomAccessFile.java:316)
at java.io.RandomAccessFile.(RandomAccessFile.java:243)
at org.eclipse.osgi.internal.location.Locker_JavaNio.lock(Locker_JavaNio.java
:36)
at org.eclipse.osgi.storagemanager.StorageManager.lock(StorageManager.java:38
8)
at org.eclipse.osgi.storagemanager.StorageManager.open(StorageManager.java:70
1)
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.(Storage.java:132)
at org.eclipse.osgi.storage.Storage.createStorage(Storage.java:85)
at org.eclipse.osgi.internal.framework.EquinoxContainer.(EquinoxContain
er.java:68)
… 4 more
2018-12-21 23:03:03.560 [SEVERE] [org.apache.karaf.main.Main] - Could not launch fram
ework
java.lang.RuntimeException: Error initializing storage.
at org.eclipse.osgi.internal.framework.EquinoxContainer.(EquinoxContain
er.java:70)
at org.eclipse.osgi.launch.Equinox.(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)
Caused by: java.io.FileNotFoundException: /var/lib/openhab2/cache/org.eclipse.osgi/.m
anager/.fileTableLock (Permission denied)
at java.io.RandomAccessFile.open0(Native Method)
at java.io.RandomAccessFile.open(RandomAccessFile.java:316)
at java.io.RandomAccessFile.(RandomAccessFile.java:243)
at org.eclipse.osgi.internal.location.Locker_JavaNio.lock(Locker_JavaNio.java
:36)
at org.eclipse.osgi.storagemanager.StorageManager.lock(StorageManager.java:38
8)
at org.eclipse.osgi.storagemanager.StorageManager.open(StorageManager.java:70
–More–(86%)