MQTT connection to 'mosquitto' was lost.... Could not initialize class com.jayway.jsonpath.internal.DefaultsImpl

I’m trying to make my first MQTT item but when its updated I get this error.

MQTT connection to ‘mosquitto’ was lost: MqttException : ReasonCode 0 : Cause : Could not initialize class com.jayway.jsonpath.internal.DefaultsImpl

I’m chekking the publish with MQTT fx and it works or I think the problem is on the Openhab side.

my item looks like this:

// Mi Flora "Flower care bacilikum"(C4:7C:8D:63:4B:50)
Number flowerCare_bacilikum_Conductivity     "Flower care bacilikum Soil Conductivity/Fertility [%d µS/cm]" <text> (g, gConductivity)  {mqtt="<[mosquitto:miflora/bacilikum:state:JSONPATH($.conductivity)]"}
Number flowerCare_bacilikum_Moisture         "Flower care bacilikum Soil Moisture [%d %%]"                  <text> (g, gMoisture)      {mqtt="<[mosquitto:miflora/bacilikum:state:JSONPATH($.moisture)]"}
Number flowerCare_bacilikum_Light            "Flower care bacilikum Sunlight Intensity [%d lux]"            <text> (g, gLight)         {mqtt="<[mosquitto:miflora/bacilikum:state:JSONPATH($.light)]"}
Number flowerCare_bacilikum_Temperature      "Flower care bacilikum Air Temperature [%.1f °C]"              <text> (g, gTemperature)   {mqtt="<[mosquitto:miflora/bacilikum:state:JSONPATH($.temperature)]"}
Number flowerCare_bacilikum_Battery          "Flower care bacilikum Sensor Battery Level [%d %%]"           <text> (g, gBattery)       {mqtt="<[mosquitto:miflora/bacilikum:state:JSONPATH($.battery)]"}

My mqtt.cfg:
mqtt:miflora/bacilikum.url=tcp://192.168.1.109:1883
mqtt:miflora/bacilikum=openHAB

the rest is set to default

Im running a miflower python scrip from https://github.com/ThomDietrich/miflora-mqtt-daemon

Can anyyone help?

mqtt.cfg:

mosquitto.url=tcp://192.168.1.109:1883

and nothing else

I made the change(thanks) but I still get the error:

I think is more an jsonpath error, maybe…

2017-08-29 16:08:23.293 [ERROR] [t.mqtt.internal.MqttBrokerConnection] - MQTT connection to broker was lost
MqttException (0) - java.lang.NoClassDefFoundError: Could not initialize class com.jayway.jsonpath.internal.DefaultsImpl
	at org.eclipse.paho.client.mqttv3.internal.CommsCallback.run(CommsCallback.java:197)[249:org.openhab.io.transport.mqtt:1.10.0]
	at java.lang.Thread.run(Thread.java:745)[:1.8.0_121]
Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.jayway.jsonpath.internal.DefaultsImpl
	at com.jayway.jsonpath.Configuration.getEffectiveDefaults(Configuration.java:48)
	at com.jayway.jsonpath.Configuration.defaultConfiguration(Configuration.java:173)
	at com.jayway.jsonpath.internal.JsonContext.<init>(JsonContext.java:52)
	at com.jayway.jsonpath.JsonPath.read(JsonPath.java:502)
	at org.eclipse.smarthome.transform.jsonpath.internal.JSonPathTransformationService.transform(JSonPathTransformationService.java:49)
	at org.openhab.core.transform.TransformationHelper$TransformationServiceDelegate.transform(TransformationHelper.java:60)
	at org.openhab.binding.mqtt.internal.MqttMessageSubscriber.processMessage(MqttMessageSubscriber.java:138)
	at org.openhab.io.transport.mqtt.internal.MqttBrokerConnection.messageArrived(MqttBrokerConnection.java:556)[249:org.openhab.io.transport.mqtt:1.10.0]
	at org.eclipse.paho.client.mqttv3.internal.CommsCallback.deliverMessage(CommsCallback.java:475)[249:org.openhab.io.transport.mqtt:1.10.0]
	at org.eclipse.paho.client.mqttv3.internal.CommsCallback.handleMessage(CommsCallback.java:379)[249:org.openhab.io.transport.mqtt:1.10.0]
	at org.eclipse.paho.client.mqttv3.internal.CommsCallback.run(CommsCallback.java:183)[249:org.openhab.io.transport.mqtt:1.10.0]
	... 1 more
2017-08-29 16:08:23.369 [ERROR] [t.mqtt.internal.MqttBrokerConnection] - MQTT connection to 'mosquitto' was lost: MqttException : ReasonCode 0 : Cause : Could not initialize class com.jayway.jsonpath.internal.DefaultsImpl
2017-08-29 16:08:23.372 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting connection helper to periodically try restore connection to broker 'mosquitto'

@Moellegaard, make sure you can access your broker outside of OH.
For example:
mosquitto_sub -h 192.168.1.109 -v -t '#'

then delete /var/lib/openhab2/config/org/openhab/mqtt.config
and restart OH.

Ok,
I can see the broker from outside OH.
I deleted the mqtt.config in OPENHABIANPI\openHAB-share\openhab2-conf\services
and restarted.
What then?

Probably the wrong file was deleted, please check here
I’m not using OPENHABIAN and cannot be more specific.

okay, I dont really understand what you want me to do?
Do you think deleting a file will resolve the problem?

You may have the old configuration cached in /var/lib/openhab2/config/org/openhab/mqtt.config or your equivalent of this file. Deleting such file will force OH to recreate it from the current ‘source’ config file (the one you deleted).

1 Like

Oh it worked.
I installed the mosquitto from openHABian configuration tool, uninstall the mqtt binding and reinstalled it and removed the added # mosquitto.clientId=openHAB in the mqtt.cgf file and it seemed to work :smile: D
I dont know excatly what did it but it works now.
Thanks so much