MQTT and OH2 - not working

Maybe this? MQTT and OH2 - not working - #6 by marcin

@stefan_bauer

To get mqtt working in OH2 you need to do the follwoing steps

  • Copy org.openhab.binding.mqtt-1.8.0-SNAPSHOT.jar from the OH18 addons to the OH2 addons folder
  • Copy org.openhab.io.transport.mqtt_^.jar from the OH18 distribution to the OH2 addons folder (you find it in /server/plugins/ folder)

Add to runtime.cfg your connection to mqtt server e.g.
mqtt:mymqtt.url=tcp://localhost:1883

Copy your OH1 mqtt lines to the OH2 /conf/item folder

Ok, thanks.

I missed the io.transport…
Now it is working.

:slight_smile:

For me this does not work any more with the 2.0b1 release (was ok before karaf implementation).
In the IDE the MQTT works fine with the latest repo.
Starting the MQTT bundle in karaf the two bundles will start, but give error (log:tail). And MQTT does not work.
Even the rendering of classic-ui and basic-ui becomes crazy.

I have no experience of MQTT before b1, but I am trying to get it up and running for brultech energy monitor.
As soon as I start oh2b1, I receive in my log;
`2016-01-17 18:04:26.929 [ERROR] [org.apache.felix.configadmin ] - [org.openhab.io.transport.mqtt.MqttService, org.osgi.service.cm.ManagedService, id=288, bundle=182/file:/home/micke/OpenHAB2/addons/org.openhab.io.transport.mqtt_1.8.0.jar]: Unexpected problem updating configuration org.openhab.mqtt
java.lang.NoClassDefFoundError: javax/net/ssl/TrustManager
at org.openhab.io.transport.mqtt.MqttService.updated(MqttService.java:80)
at org.apache.felix.cm.impl.helper.ManagedServiceTracker.updated(ManagedServiceTracker.java:189)[7:org.apache.felix.configadmin:1.8.8]
at org.apache.felix.cm.impl.helper.ManagedServiceTracker.updateService(ManagedServiceTracker.java:152)[7:org.apache.felix.configadmin:1.8.8]
at org.apache.felix.cm.impl.helper.ManagedServiceTracker.provideConfiguration(ManagedServiceTracker.java:85)[7:org.apache.felix.configadmin:1.8.8]
at org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceUpdate.provide(ConfigurationManager.java:1444)[7:org.apache.felix.configadmin:1.8.8]
at org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceUpdate.run(ConfigurationManager.java:1400)[7:org.apache.felix.configadmin:1.8.8]
at org.apache.felix.cm.impl.UpdateThread.run0(UpdateThread.java:143)[7:org.apache.felix.configadmin:1.8.8]
at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:110)[7:org.apache.felix.configadmin:1.8.8]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_66]
Caused by: java.lang.ClassNotFoundException: javax.net.ssl.TrustManager cannot be found by org.openhab.io.transport.mqtt_1.8.0
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:432)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:345)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:337)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)[:1.8.0_66]
… 9 more
2016-01-17 18:04:26.987 [INFO ] [basic.internal.servlet.WebAppServlet] - Started Basic UI at /basicui/app


Is this because of some missing dependency, or is this the error that you are experiencing @sisim ?
`

Starting with a completely fresh installation (package=standard)
copied the two “mqtt” files into the addon folder and adding the broker to the config

i get the following log-errors

2016-01-17 19:16:54.384 [ERROR] [org.eclipse.smarthome.core.transform] - [org.eclipse.smarthome.action.transformation.action(75)] Circular reference detected, getService returning null


2016-01-17 19:16:56.909 [ERROR] [org.apache.felix.configadmin ] - [org.openhab.io.transport.mqtt.MqttService, org.osgi.service.cm.ManagedService, id=261, bundle=158/file:/C:/openHAB2-lochau/addons/org.openhab.io.transport.mqtt-1.9.0-SNAPSHOT.jar]: Unexpected problem updating configuration org.openhab.mqtt
java.lang.NoClassDefFoundError: javax/net/SocketFactory
at org.openhab.io.transport.mqtt.MqttService.updated(MqttService.java:77)
at org.apache.felix.cm.impl.helper.ManagedServiceTracker.updated(ManagedServiceTracker.java:189)[7:org.apache.felix.configadmin:1.8.8]
at org.apache.felix.cm.impl.helper.ManagedServiceTracker.updateService(ManagedServiceTracker.java:152)[7:org.apache.felix.configadmin:1.8.8]
at org.apache.felix.cm.impl.helper.ManagedServiceTracker.provideConfiguration(ManagedServiceTracker.java:85)[7:org.apache.felix.configadmin:1.8.8]
at org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceUpdate.provide(ConfigurationManager.java:1444)[7:org.apache.felix.configadmin:1.8.8]
at org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceUpdate.run(ConfigurationManager.java:1400)[7:org.apache.felix.configadmin:1.8.8]
at org.apache.felix.cm.impl.UpdateThread.run0(UpdateThread.java:143)[7:org.apache.felix.configadmin:1.8.8]
at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:110)[7:org.apache.felix.configadmin:1.8.8]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_65]
Caused by: java.lang.ClassNotFoundException: javax.net.SocketFactory cannot be found by org.openhab.io.transport.mqtt_1.9.0.201601161441
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:432)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:345)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:337)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)[:1.8.0_65]
… 9 more


Hmm, after some digging into different osgi issues related to javax.net.ssl.* in eclipse mentioning something about the boot delegation.

So I just discovered the following commit:

It seems to fix the issue… more testing to be done. Maybe Kai has some more input on this.

//Jan

Compiled the latest repo (this morning…boot delegation…) and i can confirm the MQTT is running.

open issues for me:

  1. logout from karaf throws enocean exeption
  2. Since b1 the sonos control (classic-ui, basic-ui) is not updated, if you play/pause from the sonos IDE. Play/Pause from the UI are ok. (I hope it is not because of the latest sonos update.Mybe something has changed)
  1. logout from karaf throws enocean exeption

Could you please enter an issue with the exception at Issues · openhab/openhab1-addons · GitHub?

  1. Since b1 the sonos control (classic-ui, basic-ui) is not updated, if you play/pause from the sonos IDE. Play/Pause from the UI are ok. (I hope it is not because of the latest sonos update.Mybe something has changed)

Could you please enter an issue at Issues · eclipse-archived/smarthome · GitHub?

Thanks!

You can check your java configuration in your path. I had the same problem before.

@feversky
What should have changed in the java configuration from euinox to karaf ? what can i check in my path?

@sisim
I had the same error “java.lang.NoClassDefFoundError: javax/net/SocketFactory” before. And then I checked my %path% (win7), the java was configured to a wrong path, this error was gone after fixing it. It seems you have some other issues now. :relaxed:

Now I tried this with a OH2 snapshot from this week. I tried installing via Paper UI, manually downloading mqtt transport/binding 1.9 snapshots and also with the 1.8.1 addons. At best with 1.9 I get this in the log:

2016-03-13 21:54:09.039 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed.
2016-03-13 21:54:09.039 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection ‘local’

mqtt.cfg:
local.url=tcp://localhost:1883

runtime.cfg
mqtt:local.url=tcp://localhost:1883

items.cfg
String mqtt_pir “Pi PIR [%s]” (Mags) { mqtt="<[local:/sensors/motion:state:default]" }

I’ve never run mqtt in OH before, but I see “ON|OFF” with this:
$ mosquitto_sub -h localhost -t sensors/motion
…so I guess mqtt works

Any ideas? :slight_smile:

i’m a newbe to Openhab where do I find the io.transport binding?(sorry i missed where Stefan said it was in the server plugins folder)

That was still based on the old way. In the new karaf builds it is different.
to get the io transport, type the following in the OH command line
feature:install openhab-transport-mqtt

1 Like

Should i be able to see to see the Binding in the paper ui openhab2 is connecting to MQTT but I am unable to see it in openhab

You need to press “install” for the MQTT binding under extensions in PaperUI. Then afaik you will need to create your items yourself. e.g.

Number Energy_ch25 "Garage [%.2f]" <energy> (GPersist,gEnergy) {mqtt="<[broker:/house/energy/01000590_ch25_w:state:default]"}

This is for my Brultech engerymonitor reporting power consumed in my garage.

Hi @marcel_verpaalen,

Is this still valid, since I can install mqtt binding 1.9.0 with Paper UI in OH2 ?
Does it make sense to combine mqtt1.9.0 with org.openhab.binding.mqttitude-1.8.3.jar or is this obsolete in OH2?

Generally, 1.8 binding JARs are likely to have problems running under OH2. Small changes were needed to most 1.8 bindings so they would run correctly under OH2 (and continue running under 1.8). You should be able to get the MQTTitude (OwnTracks) binding from here to manually add to the addons folder, if it doesn’t install from Paper UI. The 1.9.0-SNAPSHOT MQTT binding that installs from OH2 is the one you want.

Hi @watou

Thanks for your response.
I am not sure if I got your point completely.

I installed Mqtt binding 1.9.0 (by Paper UI as you suggested). Together with mqttitude 1.8.3 (manually put into addons) it works like a charm.
(Only task is to work with owntracks)

So, what about Mqtt.io mentioned above?
Is this for sending out mqtt messages to other devices or processes?