Cannot run MQTT binding from IDE

  • Platform information:
    • Hardware: AMD64
    • OS: Windows 10
    • Java Runtime Environment: ORACLE JRE 11
    • openHAB version: 3.2.0
  • Issue of the topic: trying to run app.bndrun from ECLIPSE, getting error Unresolved requirement: Import-Package: io.netty.bootstrap; version="[4.1.0,4.2.0)"

Installed and configured ECLIPSE openhab-dev and op-enhab-addons projects. Tried milight binding - runs fine from ECLIPSE IDE. Now trying to work with mqtt binding.
Added org.openhab.binding.mqtt to POM dependencies.
Added org.openhab.binding.mqtt to “Run Bundles”
Also added org.openhab.core.io.transport.mqtt, com.hivemq.client.mqtt, com.google.dagger to “Run Bundles”

When trying to run OSGi - getting the following error

! Failed to start bundle org.openhab.binding.mqtt-3.2.0.202107220741, exception Could not resolve module: org.openhab.binding.mqtt [163]
Unresolved requirement: Import-Package: org.openhab.core.io.transport.mqtt
→ Export-Package: org.openhab.core.io.transport.mqtt; bundle-symbolic-name=“org.openhab.core.io.transport.mqtt”; bundle-version=“3.2.0.202107200307”; version=“3.2.0”; uses:=“com.hivemq.client.mqtt.lifecycle,javax.net.ssl,org.openhab.core.io.transport.mqtt.reconnect,org.osgi.service.cm”
org.openhab.core.io.transport.mqtt [164]
Unresolved requirement: Import-Package: com.hivemq.client.mqtt; version="[1.2.0,2.0.0)"
→ Export-Package: com.hivemq.client.mqtt; bundle-symbolic-name=“com.hivemq.client.mqtt”; bundle-version=“1.2.2”; version=“1.2.2”; uses:=“com.hivemq.client.mqtt.datatypes,com.hivemq.client.mqtt.lifecycle,com.hivemq.client.mqtt.mqtt3,com.hivemq.client.mqtt.mqtt5,io.reactivex,javax.net.ssl”
com.hivemq.client.mqtt [165]
Unresolved requirement: Import-Package: io.netty.bootstrap; version="[4.1.0,4.2.0)"
Unresolved requirement: Import-Package: com.hivemq.client.mqtt.datatypes; version="[1.2.0,2.0.0)"
→ Export-Package: com.hivemq.client.mqtt.datatypes; bundle-symbolic-name=“com.hivemq.client.mqtt”; bundle-version=“1.2.2”; version=“1.2.2”
Unresolved requirement: Import-Package: org.openhab.core.io.transport.mqtt.reconnect
→ Export-Package: org.openhab.core.io.transport.mqtt.reconnect; bundle-symbolic-name=“org.openhab.core.io.transport.mqtt”; bundle-version=“3.2.0.202107200307”; version=“3.2.0”; uses:=“org.openhab.core.io.transport.mqtt”

I cannot find io.netty.bootstrap package. Any help appreciated

I’m not certain that this was the proper way to do this, but I managed to run the mqtt binding in my demo.app by adding the following dependencies to the pom.xml. This worked under some of the 3.1Mx releases about 2 months ago, although I wasn’t getting the same error message as you - mine was missing io.netty.channel.epoll initially - but the same method might help you. I identified the dependency by googling the package name in the error message with maven artifactId, and picked a recent version. Per a quick search io.netty.bootstrap might be in netty-all.

<dependency>
  <groupId>io.netty</groupId>
  <artifactId>netty-transport-native-epoll</artifactId>
  <version>4.1.63.Final</version>
</dependency>
<dependency>
  <groupId>io.netty</groupId>
  <artifactId>netty-codec-http</artifactId>
  <version>4.1.63.Final</version>
</dependency>
<dependency>
  <groupId>io.netty</groupId>
  <artifactId>netty-handler-proxy</artifactId>
  <version>4.1.63.Final</version>
</dependency>

thanks, that helped

Well it helped a little bit but there is also missing something:

Resolution failed. Capabilities satisfying the following requirements could not be found:
    [<<INITIAL>>]
      ⇒ osgi.identity: (osgi.identity=org.openhab.binding.mqtt)
          ⇒ [org.openhab.binding.mqtt version=3.2.0.202109221348]
              ⇒ osgi.wiring.package: (osgi.wiring.package=com.jcraft.jzlib)

I hope you can help me. Thanks in advance.

Okay, my solution was to add

<dependency>
  <groupId>io.netty</groupId>
  <artifactId>netty-transport-native-epoll</artifactId>
  <version>4.1.63.Final</version>
</dependency>
<dependency>
  <groupId>io.netty</groupId>
  <artifactId>netty-codec-http</artifactId>
  <version>4.1.63.Final</version>
</dependency>
<dependency>
  <groupId>io.netty</groupId>
  <artifactId>netty-handler-proxy</artifactId>
  <version>4.1.63.Final</version>
</dependency>

to the pom.xml from org.openhab.demo.app. Then click Maven → Update Project (Alt + F5) and select Force Update of Snapshot/Release. In the app.bndrun I have to add

com.hivemq.client.mqtt
org.openhab.core.io.transport.mqtt
io.netty.transport-native-epoll
org.openhab.binding.mqtt (or maybe a own mqtt binding)
org.eclipse.equinox.metatype

to the Run Requirments.

Yes, I have to remove and add again org.eclipse.equinox.metatype because it was not detected. Another point ist that for me it only works if there stands [org.openhab.demo.app (implicit)] and not [Maven Dependencies]. I hope this could help.