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.(
at org.eclipse.osgi.launch.Equinox.(
at org.eclipse.osgi.launch.EquinoxFactory.newFramework(
at org.apache.karaf.main.Main.launch(
at org.apache.karaf.main.Main.main(
Caused by: Unable to create lock manager.
at org.eclipse.osgi.internal.framework.EquinoxContainer.(
… 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( ~[?:?]
at org.eclipse.osgi.internal.framework.BundleContextImpl.start( [?:?]
at org.eclipse.osgi.internal.framework.EquinoxBundle.startWorker0( ~[?:?]
at org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.startWorker( ~[?:?]
at org.eclipse.osgi.container.Module.doStart( ~[?:?]
at org.eclipse.osgi.container.Module.start( ~[?:?]
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel( ~[?:?]
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel( ~[?:?]
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel( ~[?:?]
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent( ~[?:?]
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent( ~[?:?]
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent( [?:?]
at org.eclipse.osgi.framework.eventmgr.EventManager$ [?:?]
Caused by: java.lang.IllegalStateException: Already initialzed with [org.glassfish.hk2.osgiresourcelocator.ResourceFinderImpl@36817228]
at org.glassfish.hk2.osgiresourcelocator.ResourceFinder.initialize( ~[?:?]
at org.glassfish.hk2.osgiresourcelocator.Activator.start( ~[?:?]
at org.eclipse.osgi.internal.framework.BundleContextImpl$ ~[?:?]
at org.eclipse.osgi.internal.framework.BundleContextImpl$ ~[?:?]
at Method) ~[?:?]
at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator( ~[?:?]
… 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:
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.