Persistence isnt working

Would you be willing to write this up as a tutorial under the Tutorials and Examples tag? I see a lot of people having troubles getting MySQL and JDBC in general working and it would be handy to have an easily findable posting we can point people at.

Sure, will do that. Just need to change a few layout things.

I just tried to get persistance working, but I’m not sure, what goes wrong.

ok here’s my steps:

(1) addons.cfg

# A comma-separated list of persistence services to install (e.g. "rrd4j,jpa")
persistence = mysql 	

(2) mysql.cfg

############################ mySQL Persistence Service ##################################

# the database url like 'jdbc:mysql://<host>:<port>/<database>'
mysql:url=jdbc:mysql://192.168.xx.xx/openHAB

# the database user
mysql:user=xxx

# the database password
mysql:password=xxx

# the reconnection counter
#mysql:reconnectCnt=

# the connection timeout (in seconds)
#mysql:waitTimeout=

# optional tweaking of mysql datatypes
# example as described in https://github.com/openhab/openhab/issues/710
# mysql:sqltype.string=VARCHAR(20000)

# Use MySQL Server time to store item values (=false) or use openHAB Server time (=true).
# For new installations, its recommend to set "mysql:localtime=true".
# (available since 1.9, optional, defaults to false)
#mysql:localtime=true

(3) sensoren.persist

Strategies {
	everyMinute	: "0 * * * * ?"
	every5Minutes	: "0 */5 * * * ?"
   	everyHour	: "0 0 * * * ?"
   	everyDay	: "0 0 0 * * ?"
   	everyWeek	: "0 0 0 0 * ?"
   	everyMonth	: "0 0 0 0 0 ?"

    default = everyChange
}

Items {
    * : strategy = everyMinute, everyHour, everyDay, restoreOnStartup
}

After saving, I’ve got a new table in MySQL “Items” like this

CREATE TABLE `Items` (
  `ItemId` int(11) NOT NULL AUTO_INCREMENT,
  `ItemName` varchar(200) NOT NULL,
  PRIMARY KEY (`ItemId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf16;

But this table stays empty, and there’s no other tables being created despite time strategies everyMinute and default strategy everyChange

The mySQL Persistance bündle is live (obviously):

208 | Active   |  80 | 1.9.0.201611210210    | openHAB mySQL Persistence bundle

I don’t get something out of the logs (even after log:set trace org.openhab.binding.mysql).

only thing I get:

2016-11-30 22:36:22.848 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'sensoren.persist'
2016-11-30 22:36:22.947 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'sensoren.persist'

the odd thing is the double entry of refreshing - but I get those on every occasion, should be another issue…?

I’ve seen several people have issues getting MySQL working. Unfortunately I’ve been unsuccessful helping them figure out how to make it work.

InfluxDB is awesome though. :wink:

1 Like

Thing is, the connection is there, but no values are inserted. Was this somehow the case in your unsuccessful cases? Or didn’t it connect in the first place. Perhaps it’s just a misconfiguration of strategies or items…? :thinking:

One thing I didn’t do with my (now working) persistence set-up was edit the addons.cfg file.

I found the issues with my similar problem, which might be the answer(s) to your problem. See that topic for details.

Yes, this is exactly the behavior reported. Connection is made, tables are created, but states are never saved. :frowning:

With the help of @DSTM I also did work it out. You need to name the *.persist like the name of the persistance driver. As I was using “mysql” as a name, the sensoren.persist didn’t work. After I changed it to mysql.persist it worked. To a point.

Because of my utf8 collation, the max-length of VARCHAR was limited to 16383, but the initial CREATE TABLES will add VARCHAR(20000) for String-Items. So the queries failed. I changed the collation to latin1_german1_ci, but somehow the persistance layer still knows, which Items it already put into the database and so I do constantly get some errors, tables couldn’t be found.
Is there a way to reset persistance? I dropped the database and restartet OH2, but after that the errors still remain…

I would have expected dropping the db would be sufficient. So it recreated the db with the same varchar settings as before? If so I would post an issue because it shouldn’t have done that.

For me Items and item tables are created but are all except the Items table empty.

I use MariaDB

File: jdbc.persist

persistence:default=jdbc
jdbc:tableNamePrefix=Item
jdbc:tableUseRealItemNames=false
jdbc:tableIdDigitCount=0

Strategies {
    everyHour : "0 0 * * * ?"
    everyDay  : "0 0 0 * * ?"

    default = everyChange
}
Items {
    * : strategy = everyChange,everyUpdate,restoreOnStartup
}

have also checked if dropping the db would help…

Perhaps I’ll have to be more specific, so here’s what I did:

  1. removed persistance = mysql from addons.cfg
  2. drop the database
  3. create a new empt one (this time with latin1-collation instead of utf8)
  4. started persistance with now empty database
  5. the persistance created new “Items”-Table
  6. it created some “Itemxxx”-Tables, but not nearly all
  7. inserted persistance = mysql in addons.cfg
  8. after no entries in openhab.log saved mysql.persist again

Then I’ve got this Errors in my log:

2016-12-02 18:32:59.679 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'mysql.persist'
2016-12-02 18:32:59.770 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'gGarten'.
2016-12-02 18:32:59.779 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'gJalousien'.
2016-12-02 18:32:59.787 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'gWetter'.
2016-12-02 18:32:59.797 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'gStatus'.
2016-12-02 18:32:59.805 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'OG_Flur'.
2016-12-02 18:32:59.811 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'UG_Flur'.
2016-12-02 18:32:59.816 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'UG_Heizung'.
2016-12-02 18:32:59.821 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'UG_Waschen'.
2016-12-02 18:32:59.827 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'UG_Party'.
2016-12-02 18:32:59.833 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'Garten_N'.
2016-12-02 18:32:59.839 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'Shutters'.
2016-12-02 18:32:59.844 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'Heating'.
2016-12-02 18:32:59.849 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'Temperature'.
2016-12-02 18:32:59.855 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'Windows'.
2016-12-02 18:32:59.860 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'Light_EG_WoZi_WandEss'.
2016-12-02 18:32:59.865 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'Light_OG_Flur_Ceiling'.
2016-12-02 18:32:59.871 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'Light_OG_Flur_Stairs'.
2016-12-02 18:32:59.877 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'Sensoren_Temp_Sp3Lanze'.
(...)

after waiting for the strategy to kick in (everyHour):

(...)
2016-12-02 19:00:00.804 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Could not store item 'Sensoren_Lux_S_VAD' in database with statement 'INSERT INTO Item108 (TIME, VALUE) VALUES(NOW(),?) ON DUPLICATE KEY UPDATE VALUE=?;': Table 'openHAB.Item108' doesn't exist
2016-12-02 19:00:00.811 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Could not store item 'Sensoren_Lux_S_VDD' in database with statement 'INSERT INTO Item109 (TIME, VALUE) VALUES(NOW(),?) ON DUPLICATE KEY UPDATE VALUE=?;': Table 'openHAB.Item109' doesn't exist
2016-12-02 19:00:00.818 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Could not store item 'Sensoren_Lux_S_lux' in database with statement 'INSERT INTO Item110 (TIME, VALUE) VALUES(NOW(),?) ON DUPLICATE KEY UPDATE VALUE=?;': Table 'openHAB.Item110' doesn't exist
2016-12-02 19:00:00.824 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Could not store item 'Sensoren_Lux_S_illu' in database with statement 'INSERT INTO Item111 (TIME, VALUE) VALUES(NOW(),?) ON DUPLICATE KEY UPDATE VALUE=?;': Table 'openHAB.Item111' doesn't exist
2016-12-02 19:00:00.831 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Could not store item 'Binder_Darkoutside' in database with statement 'INSERT INTO Item112 (TIME, VALUE) VALUES(NOW(),?) ON DUPLICATE KEY UPDATE VALUE=?;': Table 'openHAB.Item112' doesn't exist
2016-12-02 19:00:00.837 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Could not store item 'Binder_Nightstate' in database with statement 'INSERT INTO Item113 (TIME, VALUE) VALUES(NOW(),?) ON DUPLICATE KEY UPDATE VALUE=?;': Table 'openHAB.Item113' doesn't exist
2016-12-02 19:00:00.842 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Could not store item 'Binder_Holidays' in database with statement 'INSERT INTO Item114 (TIME, VALUE) VALUES(NOW(),?) ON DUPLICATE KEY UPDATE VALUE=?;': Table 'openHAB.Item114' doesn't exist
2016-12-02 19:00:00.848 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Could not store item 'Binder_Away' in database with statement 'INSERT INTO Item115 (TIME, VALUE) VALUES(NOW(),?) ON DUPLICATE KEY UPDATE VALUE=?;': Table 'openHAB.Item115' doesn't exist
2016-12-02 19:00:00.853 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Could not store item 'Binder_Wastegrey' in database with statement 'INSERT INTO Item116 (TIME, VALUE) VALUES(NOW(),?) ON DUPLICATE KEY UPDATE VALUE=?;': Table 'openHAB.Item116' doesn't exist
2016-12-02 19:00:00.858 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Could not store item 'Binder_Wasteyellow' in database with statement 'INSERT INTO Item117 (TIME, VALUE) VALUES(NOW(),?) ON DUPLICATE KEY UPDATE VALUE=?;': Table 'openHAB.Item117' doesn't exist
2016-12-02 19:00:00.864 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Could not store item 'Binder_Wasteblue' in database with statement 'INSERT INTO Item118 (TIME, VALUE) VALUES(NOW(),?) ON DUPLICATE KEY UPDATE VALUE=?;': Table 'openHAB.Item118' doesn't exist
2016-12-02 19:00:00.870 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Could not store item 'CurrentDate' in database with statement 'INSERT INTO Item119 (TIME, VALUE) VALUES(NOW(),?) ON DUPLICATE KEY UPDATE VALUE=?;': Table 'openHAB.Item119' doesn't exist
2016-12-02 19:00:00.875 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Could not store item 'Date' in database with statement 'INSERT INTO Item120 (TIME, VALUE) VALUES(NOW(),?) ON DUPLICATE KEY UPDATE VALUE=?;': Table 'openHAB.Item120' doesn't exist
(...)

The Table doesn’t even have those entries (it only has about 102 Items out of my >350)

This makes me think, there must be some kind of persistance for the persistance! :wink: But I don’t know where. You mean, this is a bug?

Based on the errors it looks like it failed to create all of the tables or columns for your setup.

I’d recommend the following approach.

  1. Configure the logger to put the mysql add-on into trace debug and to debug to a separate file. See: Taming openHAB 2 Logging

  2. Stop openHAB

  3. Delete everything in the MySQL database, drop the DB is probably sufficient but it has been a very long time since I’ve messed with MySQL.

  4. Start OH again and give it time to restart and do all its DB stuff.

  5. Maybe restart it again just for good measure.

  6. File an issue in the openhab1-addons repo and post the logs there.

Thanks for the help.

I did as you described and this time, I’m getting really confused. Last time I did this (without TRACE), see above, there was some Itemxxx-entries in the fresh database. This time, there’s only the “Items”-table and it stays empty - no Itemxxx-tables, but the log is just like above:

(...my .items)
2016-12-05 08:17:22.234 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'mysql.persist'
2016-12-05 08:17:28.182 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'astro.rules'
(...my .rules)
2016-12-05 08:17:32.967 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'binder.sitemap'
2016-12-05 08:17:33.774 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'binder.things'
2016-12-05 08:17:37.342 [INFO ] [.dashboard.internal.DashboardService] - Started dashboard at /start
2016-12-05 08:17:45.734 [INFO ] [basic.internal.servlet.WebAppServlet] - Started Basic UI at /basicui/app
2016-12-05 08:17:45.915 [INFO ] [arthome.ui.paper.internal.PaperUIApp] - Started Paper UI at /ui
2016-12-05 08:17:47.416 [INFO ] [ding.astro.handler.AstroThingHandler] - Scheduled astro DailyJob at midnight for thing astro:moon:home
2016-12-05 08:17:47.424 [INFO ] [ding.astro.handler.AstroThingHandler] - Scheduled astro DailyJob at midnight for thing astro:sun:home
2016-12-05 08:17:47.428 [INFO ] [ding.astro.handler.AstroThingHandler] - Scheduled astro PositionalJob with interval of 600 seconds for thing astro:moon:home
2016-12-05 08:17:47.433 [INFO ] [ding.astro.handler.AstroThingHandler] - Scheduled astro PositionalJob with interval of 600 seconds for thing astro:sun:home
2016-12-05 08:17:53.060 [INFO ] [panel.internal.HABPanelDashboardTile] - Started HABPanel at /habpanel
(...)
2016-12-05 08:18:05.978 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'gGarten'.
2016-12-05 08:18:05.984 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'gJalousien'.
2016-12-05 08:18:05.989 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'gWetter'.
2016-12-05 08:18:05.994 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'gStatus'.
2016-12-05 08:18:06.000 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'EG_WoZi'.
2016-12-05 08:18:06.005 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'EG_Kueche'.
2016-12-05 08:18:06.011 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'EG_WC'.
2016-12-05 08:18:06.016 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'EG_Flur'.
2016-12-05 08:18:06.020 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'OG_Bad'.
2016-12-05 08:18:06.025 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'OG_Schlafen'.
2016-12-05 08:18:06.029 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'OG_Flur'.
2016-12-05 08:18:06.034 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'UG_Flur'.
2016-12-05 08:18:06.038 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'UG_Heizung'.
2016-12-05 08:18:06.043 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'UG_Waschen'.
2016-12-05 08:18:06.048 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'UG_Party'.
2016-12-05 08:18:06.052 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'Garten_N'.
2016-12-05 08:18:06.058 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'Lights'.
2016-12-05 08:18:06.062 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'Shutters'.
2016-12-05 08:18:06.067 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'Heating'.
2016-12-05 08:18:06.071 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'Temperature'.
2016-12-05 08:18:06.078 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'Windows'.
2016-12-05 08:18:06.082 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'Light_EG_WoZi_LG1'.
2016-12-05 08:18:06.087 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'Light_EG_WoZi_LG2'.
2016-12-05 08:18:06.091 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'Light_EG_WoZi_LG3'.
2016-12-05 08:18:06.095 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'Light_EG_WoZi_LG4'.
2016-12-05 08:18:06.100 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'Light_EG_WoZi_WandEss'.
2016-12-05 08:18:06.105 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'Light_EG_WoZi_WandWoZi'.
(... more items to come, seems like all my items)

I also tried to name the new database differently (so the first ones all read “openHAB”, the last try was “openHAB2”), but the outcome is the same.
Sorry, I checked the wrong dates in the log! It helped! So, giving the database a completely new name worked after all! So, I have my Items-table populated and have my Itemxxx filling up. And with changing the collation to “latin1_…” there’s even enough space for VARCHAR(20000).

So my advice for similar tasks:

  1. don’t use UTF-8/16 collations at present, as they don’t allow such big VARCHARs
  2. if you want to reset your persistance, drop the database and create a new one with a different name!

I did open an issue, see https://github.com/openhab/openhab/issues/4866

This could point at a problem with timing or the like. Hopefully someone who knows the code will see the issue and fix it.

hmm… could be…
after leaving OH2 running for the day, there are quite a bit items missing - even in the newly named database. I just did add the items in the “Items”-table and created new “Itemxxx”-tables for them. This seems to work now…

But if I add new items to my config, they won’t be added to the persistence:

2016-12-05 19:11:06.958 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'binderjalousien.items'
2016-12-05 19:11:07.081 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'Shutter_OG_ges'.
2016-12-05 19:11:07.088 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'Shutter_OG_KiZiWest'.
2016-12-05 19:11:07.094 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'Shutter_OG_KiZiOst'.

I’ll wait some time, if the three new items show up sometime later in the database, then I’ll add this to the OH2-issue.

edit:
after a time (not sure, but at first since 20:35, roughly an hour later), the Items-table got the three new Items and they already got updates in the respective Itemxxx-tables.

edit2:
it’s not time-related (that was coincidence), it’s related, when the first strategy fires. At least, after I added some items with “everyChange” and changed the item, it showed in the Items-table and got populated in the Itemxxx-table.

I’m having same issues as you guys, have you found a solution? After rebooting Openhab2 I get a lot of “Can’t update database blablabla…”, “Connections timeout…”. But if I just ignore this for a day or two, it auto repair it self some how… and start to log to the DB.

With the new version of openhab2 i have no problems anymore - i would try to copy my config files and reinstall the new version.

I used this guide and now it throws this exception:

[ERROR] [org.openhab.persistence.mysql       ] - [org.openhab.persistence.mysql(243)] The activate method has thrown an exception
java.lang.IllegalAccessError: tried to access method com.mysql.jdbc.ConnectionImpl.getInstance(Ljava/lang/String;ILjava/util/Properties;Ljava/lang/String;Ljava/lang/String;)Lcom/mysql/jdbc/Connection; from class com.mysql.jdbc.NonRegisteringDriver
	at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:346)
	at java.sql.DriverManager.getConnection(DriverManager.java:664)[:1.8.0_121]
	at java.sql.DriverManager.getConnection(DriverManager.java:247)[:1.8.0_121]
	at org.openhab.persistence.mysql.internal.MysqlPersistenceService.connectToDatabase(MysqlPersistenceService.java:521)
	at org.openhab.persistence.mysql.internal.MysqlPersistenceService.activate(MysqlPersistenceService.java:190)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.8.0_121]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)[:1.8.0_121]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.8.0_121]
	at java.lang.reflect.Method.invoke(Method.java:498)[:1.8.0_121]
	at org.apache.felix.scr.impl.inject.BaseMethod.invokeMethod(BaseMethod.java:224)
	at org.apache.felix.scr.impl.inject.BaseMethod.access$500(BaseMethod.java:39)
	at org.apache.felix.scr.impl.inject.BaseMethod$Resolved.invoke(BaseMethod.java:617)
	at org.apache.felix.scr.impl.inject.BaseMethod.invoke(BaseMethod.java:501)
	at org.apache.felix.scr.impl.inject.ActivateMethod.invoke(ActivateMethod.java:302)
	at org.apache.felix.scr.impl.inject.ActivateMethod.invoke(ActivateMethod.java:294)
	at org.apache.felix.scr.impl.manager.SingleComponentManager.createImplementationObject(SingleComponentManager.java:297)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.manager.SingleComponentManager.createComponent(SingleComponentManager.java:108)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:906)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.manager.SingleComponentManager.getServiceInternal(SingleComponentManager.java:879)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:823)[32:org.apache.felix.scr:2.0.6]
	at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse$1.run(ServiceFactoryUse.java:212)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at java.security.AccessController.doPrivileged(Native Method)[:1.8.0_121]
	at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse.factoryGetService(ServiceFactoryUse.java:210)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse.getService(ServiceFactoryUse.java:111)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.internal.serviceregistry.ServiceConsumer$2.getService(ServiceConsumer.java:45)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.getService(ServiceRegistrationImpl.java:496)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.getService(ServiceRegistry.java:461)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.internal.framework.BundleContextImpl.getService(BundleContextImpl.java:619)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.apache.felix.scr.impl.manager.SingleRefPair.getServiceObject(SingleRefPair.java:72)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.inject.BindMethod.getServiceObject(BindMethod.java:648)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.manager.DependencyManager.getServiceObject(DependencyManager.java:2201)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.manager.DependencyManager.invokeUnbindMethod(DependencyManager.java:1829)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.manager.SingleComponentManager.invokeUnbindMethod(SingleComponentManager.java:394)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.manager.DependencyManager$MultipleDynamicCustomizer.removedService(DependencyManager.java:375)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.manager.DependencyManager$MultipleDynamicCustomizer.removedService(DependencyManager.java:291)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerRemoved(ServiceTracker.java:1241)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerRemoved(ServiceTracker.java:1136)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.untrack(ServiceTracker.java:996)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:1175)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.BundleComponentActivator$ListenerInfo.serviceChanged(BundleComponentActivator.java:127)[32:org.apache.felix.scr:2.0.6]
	at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:109)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:914)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:862)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:801)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.unregister(ServiceRegistrationImpl.java:222)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.unregister(AbstractComponentManager.java:908)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.unregister(AbstractComponentManager.java:873)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.manager.RegistrationManager.changeRegistration(RegistrationManager.java:139)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.manager.AbstractComponentManager.unregisterService(AbstractComponentManager.java:950)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.manager.AbstractComponentManager.doDeactivate(AbstractComponentManager.java:805)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.manager.AbstractComponentManager.deactivateInternal(AbstractComponentManager.java:787)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.manager.AbstractComponentManager.dispose(AbstractComponentManager.java:579)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.manager.ConfigurableComponentHolder.disposeComponents(ConfigurableComponentHolder.java:706)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.BundleComponentActivator.dispose(BundleComponentActivator.java:523)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.Activator.disposeComponents(Activator.java:452)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.Activator.access$300(Activator.java:54)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.Activator$ScrExtension.destroy(Activator.java:306)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.utils.extender.AbstractExtender$2.run(AbstractExtender.java:290)[32:org.apache.felix.scr:2.0.6]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_121]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_121]
	at org.apache.felix.utils.extender.AbstractExtender.destroyExtension(AbstractExtender.java:312)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.utils.extender.AbstractExtender.bundleChanged(AbstractExtender.java:186)[32:org.apache.felix.scr:2.0.6]
	at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:902)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEventPrivileged(EquinoxEventPublisher.java:165)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:75)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:67)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor.publishModuleEvent(EquinoxContainerAdaptor.java:102)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.container.Module.publishEvent(Module.java:466)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.container.Module.doStop(Module.java:624)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.container.Module.stop(Module.java:488)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.decStartLevel(ModuleContainer.java:1623)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1542)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.container.SystemModule.stopWorker(SystemModule.java:248)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.internal.framework.EquinoxBundle$SystemBundle$EquinoxSystemModule.stopWorker(EquinoxBundle.java:144)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.container.Module.doStop(Module.java:626)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.container.Module.stop(Module.java:488)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.container.SystemModule.stop(SystemModule.java:186)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.internal.framework.EquinoxBundle$SystemBundle$EquinoxSystemModule$1.run(EquinoxBundle.java:159)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at java.lang.Thread.run(Thread.java:745)[:1.8.0_121]
[WARN ] [org.openhab.persistence.mysql       ] - FrameworkEvent WARNING - org.openhab.persistence.mysql
org.osgi.framework.ServiceException: org.apache.felix.scr.impl.manager.SingleComponentManager.getService() returned a null service object
	at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse.factoryGetService(ServiceFactoryUse.java:232)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse.getService(ServiceFactoryUse.java:111)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.internal.serviceregistry.ServiceConsumer$2.getService(ServiceConsumer.java:45)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.getService(ServiceRegistrationImpl.java:496)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.getService(ServiceRegistry.java:461)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.internal.framework.BundleContextImpl.getService(BundleContextImpl.java:619)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.apache.felix.scr.impl.manager.SingleRefPair.getServiceObject(SingleRefPair.java:72)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.inject.BindMethod.getServiceObject(BindMethod.java:648)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.manager.DependencyManager.getServiceObject(DependencyManager.java:2201)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.manager.DependencyManager.invokeUnbindMethod(DependencyManager.java:1829)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.manager.SingleComponentManager.invokeUnbindMethod(SingleComponentManager.java:394)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.manager.DependencyManager$MultipleDynamicCustomizer.removedService(DependencyManager.java:375)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.manager.DependencyManager$MultipleDynamicCustomizer.removedService(DependencyManager.java:291)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerRemoved(ServiceTracker.java:1241)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerRemoved(ServiceTracker.java:1136)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.untrack(ServiceTracker.java:996)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:1175)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.BundleComponentActivator$ListenerInfo.serviceChanged(BundleComponentActivator.java:127)[32:org.apache.felix.scr:2.0.6]
	at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:109)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:914)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:862)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:801)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.unregister(ServiceRegistrationImpl.java:222)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.unregister(AbstractComponentManager.java:908)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.unregister(AbstractComponentManager.java:873)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.manager.RegistrationManager.changeRegistration(RegistrationManager.java:139)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.manager.AbstractComponentManager.unregisterService(AbstractComponentManager.java:950)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.manager.AbstractComponentManager.doDeactivate(AbstractComponentManager.java:805)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.manager.AbstractComponentManager.deactivateInternal(AbstractComponentManager.java:787)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.manager.AbstractComponentManager.dispose(AbstractComponentManager.java:579)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.manager.ConfigurableComponentHolder.disposeComponents(ConfigurableComponentHolder.java:706)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.BundleComponentActivator.dispose(BundleComponentActivator.java:523)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.Activator.disposeComponents(Activator.java:452)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.Activator.access$300(Activator.java:54)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.Activator$ScrExtension.destroy(Activator.java:306)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.utils.extender.AbstractExtender$2.run(AbstractExtender.java:290)[32:org.apache.felix.scr:2.0.6]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_121]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_121]
	at org.apache.felix.utils.extender.AbstractExtender.destroyExtension(AbstractExtender.java:312)[32:org.apache.felix.scr:2.0.6]
	at org.apache.felix.utils.extender.AbstractExtender.bundleChanged(AbstractExtender.java:186)[32:org.apache.felix.scr:2.0.6]
	at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:902)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEventPrivileged(EquinoxEventPublisher.java:165)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:75)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:67)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor.publishModuleEvent(EquinoxContainerAdaptor.java:102)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.container.Module.publishEvent(Module.java:466)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.container.Module.doStop(Module.java:624)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.container.Module.stop(Module.java:488)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.decStartLevel(ModuleContainer.java:1623)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1542)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.container.SystemModule.stopWorker(SystemModule.java:248)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.internal.framework.EquinoxBundle$SystemBundle$EquinoxSystemModule.stopWorker(EquinoxBundle.java:144)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.container.Module.doStop(Module.java:626)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.container.Module.stop(Module.java:488)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.container.SystemModule.stop(SystemModule.java:186)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.internal.framework.EquinoxBundle$SystemBundle$EquinoxSystemModule$1.run(EquinoxBundle.java:159)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at java.lang.Thread.run(Thread.java:745)[:1.8.0_121]

@dikkedimi,
in openHAB 2 I would recommend jdbc binding, it is stable and works very well.

A. Go into Paper UI-> Add-ons->Persistence and choose JDBC Persistence MySQL.
B. Goto /conf/services and create a file jdbc.cfg with contend like:

url=jdbc:mysql://192.168.0.1:3306/testMysql (change for your needs)
user=user
password=pass
tableNamePrefix=Item (IMPORTANT if you want to use an existing MYSQL database)
tableUseRealItemNames=false
tableIdDigitCount=0

C. Go into Paper UI->Configuration->System scroll to Persistence and select jdbc as default Service.

D. In /conf/persistence edit jdbc.persist for your needs.

If everything goes well, then you get no error messages more. :slight_smile:

1 Like

@lewie thanks!

I had been observing the same condition as described earlier in the thread: database and an ‘items’ table would get created, though never populated. I’m was using the JDBC persistence service for MySQL and Sqlite without success.

I understood that the .persist file needed specific naming, and was naming my .persist file after the database technology (mysql.persist or sqlite.persist). It wasn’t until I read your posting that I realized that the .persist file needed to be named jdbc.persist.

All is working as expected now, thank you!