OpenHAB will not restart after clearing cache

Hardware: Intel Q9650 on Dell 0G261D motherboard
OS: Ubuntu 18.04.1 LTS
JRE: OpenJDK 1.8.0_192
OpenHAB 2.4

Due to some other issues I was attempting to clear my cache which apparently failed spectacularly. I attempting to clear the contents of the /var/lib/openhab2/cache folder, I inadvertently deleted the folder. I recreated it but openhab2.service would not start. I then checked and adjusted the cache folder permissions and the system seems to be writing to it. Now in service --status-all openhab2 is showing as running…but it’s not. I get no response from it remotely. Within the logs (when it was still generating entries, it no longer is) the following was generated:

2019-09-29 14:36:41.386 [SEVERE] [org.apache.karaf.main.Main] - Could not launch framework
java.lang.RuntimeException: Error initializing storage.
at org.eclipse.osgi.internal.framework.EquinoxContainer.(EquinoxContainer.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.IOException: Unable to create lock manager.
at org.eclipse.osgi.storagemanager.StorageManager.open(StorageManager.java:698)
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.(EquinoxContainer.java:68)
… 4 more

2019-09-29 14:44:04.349 [WARN ] [org.apache.karaf.main.Main ] - Lock lost. Setting startlevel to 1
2019-09-29 14:44:05.927 [ERROR] [.glassfish.hk2.osgi-resource-locator] - FrameworkEvent ERROR - org.glassfish.hk2.osgi-resource-locator
org.osgi.framework.BundleException: Exception in org.glassfish.hk2.osgiresourcelocator.Activator.start() of bundle org.glassfish.hk2.osgi-resource-locator.
at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:800) ~[?:?]
at org.eclipse.osgi.internal.framework.BundleContextImpl.start(BundleContextImpl.java:729) [?:?]
at org.eclipse.osgi.internal.framework.EquinoxBundle.startWorker0(EquinoxBundle.java:933) ~[?:?]
at org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.startWorker(EquinoxBundle.java:309) ~[?:?]
at org.eclipse.osgi.container.Module.doStart(Module.java:581) ~[?:?]
at org.eclipse.osgi.container.Module.start(Module.java:449) ~[?:?]
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1634) ~[?:?]
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1614) ~[?:?]
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1585) ~[?:?]
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1528) ~[?:?]
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) ~[?:?]
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) [?:?]
at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340) [?:?]
Caused by: java.lang.IllegalStateException: Already initialzed with [org.glassfish.hk2.osgiresourcelocator.ResourceFinderImpl@36817228]
at org.glassfish.hk2.osgiresourcelocator.ResourceFinder.initialize(ResourceFinder.java:57) ~[?:?]
at org.glassfish.hk2.osgiresourcelocator.Activator.start(Activator.java:55) ~[?:?]
at org.eclipse.osgi.internal.framework.BundleContextImpl$3.run(BundleContextImpl.java:779) ~[?:?]
at org.eclipse.osgi.internal.framework.BundleContextImpl$3.run(BundleContextImpl.java:1) ~[?:?]
at java.security.AccessController.doPrivileged(Native Method) ~[?:?]
at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:772) ~[?:?]
… 12 more
That last entry was made several times.

What are the ownership and permissions on the cache foulder you recreated. If it’s not owned by openhab or otherwise that user doesn’t have permission to write to it that could cause this problem.

Note that it’s best to clear the cache using openhab-cli when possible to about issues like this. openhab-cli also has a fix permissions option that would fix it if this is the root of your problem.

openhab is listed three times in the folder permissions:
drwxrwxrwx 3 root root 4096.
drwxrwxrwx 12 openhab openhab 4096…
-rw-rw-rw- 1 openhab openhab 31909 1569785988674.log
drwxrwxrwx 194 openhab openhab 4096 org.eclipse.osgi

It looks as if it should be able to write to the folder?

Well, I sort of gave up and reinstalled OpenHAB, then copied my configuration files back over. That seemed to go well and the log files indicate happiness, however when I opened the web interface I was prompted to set up UI. I inadvertently blew past this and now I get the screen:
image
and I’m unsure how to add PaperUI or any of the others!

solved that problem:

For those looking for the command:

sudo openhab-cli reset-ownership

This came in quite useful for myself previously.