MQTT persistence in OH2 not working

I’m trying to get MQTT persistence set back up under openHAB 2 (was working previously with 1.8.3). I’m currently using build 560 of OH2. Here are the debug messages that MQTT is logging:

2016-10-31 15:13:03.542 [DEBUG] [org.openhab.binding.mqtt] - BundleEvent STARTING - org.openhab.binding.mqtt
2016-10-31 15:13:03.543 [DEBUG] [org.openhab.binding.mqtt.internal.MqttActivator] - MQTT binding has been started.
2016-10-31 15:13:03.561 [DEBUG] [org.openhab.binding.mqtt] - ServiceEvent REGISTERED - {org.openhab.model.item.binding.BindingConfigReader, org.openhab.binding.mqtt.MqttBindingProvider}={component.name=org.openhab.binding.mqtt.genericbindingprovider, component
.id=170, service.id=299, service.bundleid=193, service.scope=bundle} - org.openhab.binding.mqtt
2016-10-31 15:13:03.585 [DEBUG] [org.openhab.binding.mqtt.internal.MqttEventBusBinding] - MQTT: Activating event bus binding.
2016-10-31 15:13:03.590 [DEBUG] [org.openhab.binding.mqtt] - ServiceEvent REGISTERED - {org.osgi.service.event.EventHandler, org.osgi.service.cm.ManagedService}={event.topics=openhab/*, service.pid=org.openhab.mqtt-eventbus, component.name=org.openhab.binding.
mqtt.eventbus, component.id=171, service.id=301, service.bundleid=193, service.scope=bundle} - org.openhab.binding.mqtt
2016-10-31 15:13:03.591 [DEBUG] [org.openhab.binding.mqtt] - ServiceEvent REGISTERED - {org.osgi.service.event.EventHandler}={event.topics=openhab/*, component.name=org.openhab.binding.mqtt.MqttItemBinding, component.id=172, service.id=302, service.bundleid=19
3, service.scope=bundle} - org.openhab.binding.mqtt
2016-10-31 15:13:03.607 [DEBUG] [org.openhab.binding.mqtt] - BundleEvent STARTED - org.openhab.binding.mqtt
2016-10-31 15:13:03.991 [DEBUG] [org.openhab.persistence.mqtt] - BundleEvent STARTING - org.openhab.persistence.mqtt
2016-10-31 15:13:03.997 [DEBUG] [org.openhab.persistence.mqtt] - ServiceEvent REGISTERED - {org.openhab.core.persistence.PersistenceService}={service.pid=org.openhab.mqtt-persistence, broker=ocjtech, topic=openhab, component.name=org.openhab.persistence.mqtt, 
message=%1$s, %3$s, component.id=185, service.id=326, service.bundleid=197, service.scope=bundle} - org.openhab.persistence.mqtt
2016-10-31 15:13:04.014 [DEBUG] [org.openhab.persistence.mqtt.internal.MqttPersistenceService] - Deactivating MQTT Persistence
2016-10-31 15:13:04.014 [DEBUG] [org.openhab.persistence.mqtt.internal.MqttPersistenceService] - Configuration updated for MQTT Persistence.
2016-10-31 15:13:04.014 [DEBUG] [org.openhab.persistence.mqtt.internal.MqttPersistenceService] - Activating MQTT Persistence
2016-10-31 15:13:04.135 [DEBUG] [org.openhab.persistence.mqtt] - BundleEvent STARTED - org.openhab.persistence.mqtt
2016-10-31 15:13:05.770 [ERROR] [org.openhab.persistence.mqtt.internal.MqttPersistenceService] - Error sending persistency message for item 'nest_structure_home_name' : java.lang.NullPointerException

Here’s my mqtt.cfg:

ocjtech.url=tcp://192.168.241.61:1883
ocjtech.clientId=openhab
ocjtech.qos=1

And my mqtt-persistence.cfg:

broker=ocjtech
topic=openhab
message=%1$s, %3$s

mqtt.persist:

Strategies {
        everyHour : "0 0 * * * ?"
        default = everyChange
}
Items {
        // persist all items every hour and on every change
        * : strategy = everyChange, everyHour
}

The null pointer exception errors keep repeating every time there’s an item change and wireshark shows no connections between openHAB and the MQTT broker.

Hi,

Did you get the solution of it, I am also facing the same issue…

Thanks
Shamit

1 Like

I’m also running into this issue after having updated. Did either of you ever find a fix?

The original problem was a while ago so I don’t recall what the original fix was, but recently after the 2.1 update I was having a problem with MQTT and uninstalling one of the MQTT bundles and reinstalling it fixed things. I don’t remember exactly which one anymore.

That did it for me too. Wound up re-installing all of my bundles. Ended up fixing another issue I had as well.

Thanks!