[SOLVED] Problem with MQTT & JSONPATH transformation

I’m trying to set up a Sonoff Pow that I’ve reflashed with the Tasmota firmware and I’m having problems with reading the energy monitoring that the Sonoff Pow is sending. Each time the energy readings get sent out by the Pow, I get the following log message and the MQTT binding crashes and restarts. I’ve tried uninstalling and reinstalling the JSONPATH transformation but that didn’t help.

2017-08-06 05:04:20.819 [ERROR] [org.openhab.io.transport.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)[213:org.openhab.io.transport.mqtt:1.10.0]
        at java.lang.Thread.run(Thread.java:745)[:1.8.0_112]
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)[213:org.openhab.io.transport.mqtt:1.10.0]
        at org.eclipse.paho.client.mqttv3.internal.CommsCallback.deliverMessage(CommsCallback.java:475)[213:org.openhab.io.transport.mqtt:1.10.0]
        at org.eclipse.paho.client.mqttv3.internal.CommsCallback.handleMessage(CommsCallback.java:379)[213:org.openhab.io.transport.mqtt:1.10.0]
        at org.eclipse.paho.client.mqttv3.internal.CommsCallback.run(CommsCallback.java:183)[213:org.openhab.io.transport.mqtt:1.10.0]
        ... 1 more

Hi, i’m trying for the first time to use JSONPATH and am getting the same error:

22:39:42.265 [ERROR] [home.model.script.Sensibo read state] - Error was caught:
java.lang.NoClassDefFoundError: net/minidev/json/writer/JsonReaderI
22:39:43.083 [ERROR] [me.model.script.Sensibo measurements] - Error was caught:
java.lang.NoClassDefFoundError: Could not initialize class com.jayway.jsonpath.i
nternal.DefaultsImpl

seems like there’s something broken in JsonPath (?)

thanks
-yair

I’ve using JSONPATH successfully in my Sensibo project, so it might help as an example:

@michaeldavie I don’t think it’s a matter of proper usage, there’s something wrong internally with the JSONPATH transformation. Perhaps a missing jar file?

Did you find a solution? I have the same problem.

@jcollie @Moellegaard did you follow the instructions given at:

Sorry, Im getting this error when trying to get the miflower to work, It look like the same problem.

 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'

The examples at https://github.com/arendst/Sonoff-Tasmota/wiki/openHAB might still help understand the usage.
Did you try without JSONpath? Are you receiving the JSON string you are expecting? Is the jsonpath transformation installed?

I made it work, In the first place I didnt have the JSONpath transformation installed.

with the help from @AndrewZ who suggested to delete:

/var/lib/openhab2/config/org/openhab/mqtt.config

There was some old not updated information in this.

Then 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.

1 Like