Can't get persistence running

I’m currently trying to add persistence to my openHab installation. It’s using the official docker image, with mounted /openhab/conf and /openhab/addons directories.

Unfortunately I’m not successful. After trying several hours with jdbc (following http://docs.openhab.org/addons/persistence/jdbc/readme.html) and not even getting a single log entry or database table, I now tried to use jpa. This way obviously at least the config is respected.

Following the description at http://docs.openhab.org/addons/persistence/jpa/readme.html, I put the postgresql driver file postgresql-9.4-1206-jdbc41.jar to /openhab/addons.
Once this file is placed there, openhab complains at startup with an OSGi exception:

2017-10-13 12:03:07.414 [WARN ] [org.apache.felix.fileinstall        ] - Error while starting bundle: file:/openhab/addons/postgresql-9.4-1206-jdbc41.jar
org.osgi.framework.BundleException: Could not resolve module: org.postgresql.jdbc41 [9]
  Unresolved requirement: Import-Package: javax.sql

        at org.eclipse.osgi.container.Module.start(Module.java:434)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
        at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:392)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
        at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1253)[4:org.apache.felix.fileinstall:3.5.6]
        at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1225)[4:org.apache.felix.fileinstall:3.5.6]
        at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:512)[4:org.apache.felix.fileinstall:3.5.6]
        at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:361)[4:org.apache.felix.fileinstall:3.5.6]
        at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:312)[4:org.apache.felix.fileinstall:3.5.6]

During startup there are several jpa related error messages so I assume in the jpa way at least the config is respected and I hope that I just have to solve that OSGi Bundle problem.

Unfortunately I’m not used to OSGi so I’m not sure how to get javax.sql to the classpath (or some OSGi Context?!) Does anyone have an idea how I get this working?

Many Thanks!

Looks like the system is trying to start the driver jar as if it were an addon.

What’s in your addons.cfg file?

Hi namraccr,
I swear I didn’t change anything but now it’s a step further (don’t understand why). Last time I started openhab, I got the exception above and didn’t see anything in the database.

Now when I start openhab, there are still exceptions but at least it looks like the database is written now. I see the historic_item table now.

Now I get some new Exceptions (see logfile: https://1drv.ms/u/s!AtimWTtqM_muiaZBj6fRR9Y8MLFRwQ)

Actually I’m not sure how to interpret these exceptions. What I see is that obviously the saved state is obviously only partly read from the database:


As you can see the buttons don’t have a state, but the Rollershutters (Jalousie) get their state after about 30-60 sek.

I still say this sounds suspiciously like a defect.

In 1.8.3 (I know it’s old) I had persistence configured through jdbc and derby by putting the derby jar in the addons directory.

But maybe I just don’t know enough about OH2.