[SOLVED] Karaf error when starting openhab2 on rpi3

Hi i had issue like this…
not sure if the same …try to see if this helps

1 Like

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)

Dec 21 20:22:40 openHABianPi karaf[8327]: java.io.FileNotFoundException: /var/lib/openhab2/tmp/karaf.pid (Permission denied)

looks like tmp file … maybe some kind of cleanup… back up before you do anything

I have tried that post you suggested and openHAB is starting but throwing up same code and a karaf permission error

● 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.<init>(FileOutputStream.java:213) Dec 21 20:22:40 openHABianPi karaf[8327]: at java.io.FileOutputStream.<init>(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 would I go about doing that?

as i said backup !!!

and try to follow this

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

and then try:

sudo su
systemctl stop openhab2
mv /var/log/openhab2/openhab.log /var/log/openhab2/openhab.log.old
chown -R openhab:openhab /var/lib/openhab2/cache /var/lib/openhab2/tmp
systemctl start openhab2
tail -f /var/log/openhab2/openhab.log
1 Like

Ok so now my sitemap is showing up on my iOS app but still no control off the items. Checked the permissions of the items file and it says root root.

Also checked the status of openHAB and getting the same errors. I have changed the permission on the files you suggested.

` 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 21:28:40 GMT; 26min ago
Docs: https://www.openhab.org/docs/
https://community.openhab.org
Process: 12808 ExecStop=/usr/share/openhab2/runtime/bin/karaf stop (code=exited, status=1/FAILURE)
Main PID: 12948 (java)
CGroup: /system.slice/openhab2.service
└─12948 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab.runtime=/usr/share/openhab2/runtime -Dopenhab
Dec 21 21:30:55 openHABianPi karaf[12948]: at io.netty.util.concurrent.DefaultPromise.setSuccess(DefaultPromise.java:397)
Dec 21 21:30:55 openHABianPi karaf[12948]: at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:151)
Dec 21 21:30:55 openHABianPi karaf[12948]: at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.jaDec 21 21:30:55 openHABianPi karaf[12948]: at java.lang.Thread.run(Thread.java:748)
Dec 21 21:30:55 openHABianPi karaf[12948]: java.lang.NoClassDefFoundError: io/netty/util/concurrent/DefaultPromise$2
Dec 21 21:30:55 openHABianPi karaf[12948]: at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:589)
Dec 21 21:30:55 openHABianPi karaf[12948]: at io.netty.util.concurrent.DefaultPromise.setSuccess(DefaultPromise.java:397)
Dec 21 21:30:55 openHABianPi karaf[12948]: at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:151)
Dec 21 21:30:55 openHABianPi`

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`

permissions look good. anything useful inside /var/log/openhab2/openhab.log ?

You have 2 dump files in userdata… that’s not good :slight_smile:

what is your java version?

java -version

try to clean the cache again and monitor the log file

openhab-cli stop
openhab-cli clean-cache
openhab-cli reset-ownership
openhab-cli start

This is the log

`[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`

Java…
22:47:31] openhabian@openHABianPi:~$ java -version openjdk version "1.8.0_152" OpenJDK Runtime Environment (Zulu Embedded 8.25.0.76-linux-aarch32hf) (build 1.8.0_152-b76) OpenJDK Client VM (Zulu Embedded 8.25.0.76-linux-aarch32hf) (build 25.152-b76, mixed mode, Evaluation)

i need a bit more of the log output

tail -f does a continuous monitoring of the logfile and prints only a few lines at the end of the file

try to make a new log file (remove or rename the old one) and post the entire new one from the start

sudo su
systemctl stop openhab2
mv /var/log/openhab2/openhab.log /var/log/openhab2/openhab.log.old
systemctl start openhab2
more /var/log/openhab2/openhab.log

java is ok (but a bit old for the openhabcloud connector… you should upgrade it if possible to >161)

`

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%)

`

How would I go about updating the java?

ls -al /var/lib/openhab2/cache/org.eclipse.osgi/.manager/

first fix the permissions problems, get OH2 up and running and then we deal with that. step by step :slight_smile:

I hope that your SD Card is in good health :stuck_out_tongue:

All the files are root root

root has been a bad, bad boy

again (perform these exactly as below):

sudo su
systemctl stop openhab2
mv /var/log/openhab2/openhab.log /var/log/openhab2/openhab.log.old
openhab-cli clean-cache
systemctl start openhab2
more /var/log/openhab2/openhab.log

Do I need to change the permission to Openhab first or just do what you quoted?