Unable to resolve Modbus binding dependencies

Hello, I’m pretty new to programming and currently, I need help with my project. I’m trying to create a binding for Modbus communication with RS485 device and decided to use the already existing add-on Modbus binding.

Setup:

  1. I’m using Ubuntu 18.04 and Eclipse IDE 2019-03 set up with OpenHAB, setup was done using official documentation.
  2. I performed mvn clean install on the Modbus binding.
  3. Add binding to /openhab-distro/launch/app/pom.xml as a dependency.
  4. Trough IDE add binding to run requirements and try to resolve.

Resolve response:
Resolution failed. Capabilities satisfying the following requirements could not be found: [<<INITIAL>>] ⇒ osgi.identity: (osgi.identity=org.openhab.binding.modbus) ⇒ [org.openhab.binding.modbus version=2.5.0.201909181149] ⇒ osgi.wiring.package: (&(osgi.wiring.package=org.openhab.io.transport.modbus)) [org.openhab.core.test version=2.5.0.201909180303] ⇒ osgi.wiring.package: (&(osgi.wiring.package=org.junit)) [org.apache.aries.jpa.container version=2.7.0] ⇒ osgi.service: (objectClass=javax.persistence.spi.PersistenceProvider) [org.openhab.core.io.transport.serial.javacomm version=2.5.0.201909180325] ⇒ osgi.wiring.package: (&(osgi.wiring.package=javax.comm))

What I tried:

  1. I tried adding the missing dependencies to binding pom.xml, creating /lib and using .jar files.
  2. I added dependencies to /openhab-distro/launch/app/pom.xml and /bom/openhab-addons/pom.xml and performed mvn clean install.
  3. I followed Build System documentation on adding dependencies and tried everything that I could find and understand on this in community forums, moistly later half of this: https://community.openhab.org/t/need-some-help-with-setup-to-create-new-binding-using-maven-bnd/70901/17.

In the end, nothing worked and I get the same massage.

What I want to ask:

  1. Is this problem caused by missing dependencies or is it different problem entirely?
  2. How to add dependencies?
  3. Is there some kind of example or documentation on creating Modbus, RS485 communication binding from scratch.

I don’t have answers to all of your questions as I’m not completely sure what you have done or what is in your current pom and feature files. But the error seems to indicate you miss org.openhab.io.transport.modbus. You might need to add that dependency also to you demo app pom and then add it to the resolve list. Although I’m not sure if it actually would resolve as a dependency when you would add the modbus binding. But given your error message it doesn’t.

There is a developers page for extending modbus. Did you see that? It doesn’t seem to available via the documentation page, but it’s here: https://github.com/openhab/openhab2-addons/blob/master/bundles/org.openhab.binding.modbus/DEVELOPERS.md

1 Like

Thank you for your response.

Before posting my question I did try to add org.openhab.io.transport.modbus to my demo app pom file and resolving it but the response is almost the same. So I thought that the problem was with Modbus binding.

When resolving org.openhab.io.transport.modbus and org.openhab.binding.modbusI get this:

Resolution failed. Capabilities satisfying the following requirements could not be found:

[<<INITIAL>>]
  ⇒ osgi.identity: (osgi.identity=org.openhab.io.transport.modbus)
      ⇒ [org.openhab.io.transport.modbus version=2.5.0.201909190616]
          ⇒ osgi.wiring.package: (&(osgi.wiring.package=net.wimpi.modbus)(&(version>=1.2.0)(!(version>=2.0.0))))
[org.apache.aries.jpa.container version=2.7.0]
  ⇒ osgi.service: (objectClass=javax.persistence.spi.PersistenceProvider)
[org.openhab.core.test version=2.5.0.201909190302]
  ⇒ osgi.wiring.package: (&(osgi.wiring.package=org.junit))
[org.openhab.core.io.transport.serial.javacomm version=2.5.0.201909190324]
  ⇒ osgi.wiring.package: (&(osgi.wiring.package=javax.comm))

The dependencies I added to pom are:

  • org.junit
  • javax.comm
  • javax.peristance(there is org.apache.aries.jpa.javax.persistance_2.1 in repos but it doesent resolve the reqirement)
  • net.wimpi

Dependencies from pom:

<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.12</version>
     <scope>provided</scope>
</dependency>
<dependency>
   <groupId>org.vesalainen.comm</groupId>
   <artifactId>javaxcomm</artifactId>
   <version>1.0.1</version>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>net.wimpi</groupId>
    <artifactId>jamod</artifactId>
    <version>1.2</version>
     <scope>provided</scope>
</dependency>
<dependency>
    <groupId>javax.persistence</groupId>
    <artifactId>persistence-api</artifactId>
    <version>1.0</version>
    <scope>provided</scope>
</dependency>

As stated before I tried to add these dependencies to /bom/openhab-addons/pom.xml , binding and demo app pom files then performing mvn clean install.

Now I will try to add them as bundles in Modbus binding fetures.xml file as it was describes in Build system documentation and make update on the results.

Some comments:

  1. The /bom/openhab-addons/pom.xml is the pom of the dependency org.openhab.addons.bom.openhab-addons in the demo app. I don’t know when you installed Eclipse. But it’s recommended to remove that dependency from the demo app as it results in all addons to be downloaded. Instead only include the bindings you want to use in you demo pom. You can copy these dependencies from the /bom/openhab-addons/pom.xml.
  2. You don’t need to add the dependencies to junit, javaxcomm and persistence-api. These are dependencies that are inherited via dependency but not relevant here. It’s a bit confusion. But when there is a resolve error it will also show these other resolve issues. The first message is only relevant here.
  3. The dependencies in the pom (I’m assuming this is the demo pom) should not be scope provided. That is for the binding pom. Where the dependency is derived via the feature.xml and therefor for the binding it’s provided. But the demo pom is needs all dependencies.
  4. Not sure if removing provided will already solves it. But else you need to add (drag from Browse Repos) the jamod also to Run Requirement (but maybe you already was aware of this).