Dependency problem with maven

Hi Guys,
I’m a new Java programmer (I hava 15+ years of experience in C and other languages) and I’m experiencing some problem building my first binding.

Everything seems working with the eclipse demo app and I can debug my code, but, once I change the item state the OFF command is not sended to my channel (ON command is sent and handled properly indeed).

Taking a look here: Strange behaviour of handleCommand function in my plugin - Development / Add-ons - openHAB Community seems that is a problem related to the debug with eclipse.

So, my idea is to setup a demo server and install my binding. So I run

mvn clean install

in my command prompt and it cannot resolve dependencies.

My pom.xml looks like:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">

  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>org.openhab.addons.bundles</groupId>
    <artifactId>org.openhab.addons.reactor.bundles</artifactId>
    <version>4.1.0-SNAPSHOT</version>
  </parent>

  <artifactId>org.openhab.binding.threadcoap</artifactId>
  <dependencies>
    <!-- https://mvnrepository.com/artifact/org.eclipse.californium/californium-core -->
    <dependency>
      <groupId>org.eclipse.californium</groupId>
      <artifactId>californium-core</artifactId>
      <version>2.7.4</version>
      <scope>compile</scope>
    </dependency>
  </dependencies>

  <name>openHAB Add-ons :: Bundles :: ThreadCoap Binding</name>
</project>

and the error from mvn is:

[ERROR] Failed to execute goal org.apache.karaf.tooling:karaf-maven-plugin:4.4.3:verify (karaf-feature-verification) on project org.openhab.binding.threadcoap: Feature resolution failed for [openhab-binding-threadcoap/4.1.0.SNAPSHOT]
[ERROR] Message: Unable to resolve root: missing requirement [root] osgi.identity; osgi.identity=openhab-binding-threadcoap; type=karaf.feature; version=4.1.0.SNAPSHOT; filter:="(&(osgi.identity=openhab-binding-threadcoap)(type=karaf.feature)(version>=4.1.0.SNAPSHOT))" [caused by: Unable to resolve openhab-binding-threadcoap/4.1.0.SNAPSHOT: missing requirement [openhab-binding-threadcoap/4.1.0.SNAPSHOT] osgi.identity; osgi.identity=org.openhab.binding.threadcoap; type=osgi.bundle; version="[4.1.0.202308241730,4.1.0.202308241730]"; resolution:=mandatory [caused by: Unable to resolve org.openhab.binding.threadcoap/4.1.0.202308241730: missing requirement [org.openhab.binding.threadcoap/4.1.0.202308241730] osgi.wiring.package; filter:="(&(osgi.wiring.package=org.eclipse.californium.core)(version>=2.7.0)(!(version>=3.0.0)))"]]

Edit: Sorry, mispressed submit too early :D.

Anyway, does anyone has any idea about the solution?

Try a higher level than 2.7? It looks like up to 3.9 is available.

Try adding openhab-transport-coap to your feature.xml file similar to how it’s done in the Shelly Binding:

No luck, thanks anyway for your suggestion!

Ok, that worked, I had to remove the dependency on the POM file and add the feature on the feature.xml file so I’m expecting that a runtime californium version will be used, but why?

Am I missing something?

Thanks for your support anyway!

1 Like

This goal checks that your Karaf feature can be installed. So it checks if all the required packages imported by the bundles installed by your Karaf feature can be resolved. So either all required packages should be exported by the bundles in your feature or provided by some other feature. openHAB already provides the openhab-transport-coap feature which provides the Californium packages. So if you add a feature dependency on openhab-transport-coap you make sure that this feature will also be installed whenever your add-on feature is installed.

Sorry for the late reply but many thanks to take time to explain me the matter!

BEst
Alessio

1 Like