Unresolved requirement javax.measure

I compiled the binding in eclipse under the openhab-distro main, but when I attempt to install the binding on my 4.0.2 via the add-on folder, I get the following error. I also tried the openhab-distro 4.0.x. Any hints would be greatly appreciated.

2023-08-22 14:34:02.412 [WARN ] [org.apache.felix.fileinstall        ] - Error while starting bundle: file:/usr/share/openhab/addons/org.openhab.binding.haywardomnilogic-4.1.0-SNAPSHOT.jar
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.haywardomnilogic [286]
  Unresolved requirement: Import-Package: javax.measure; version="[2.2.0,3.0.0)"

Add a temporary hack to your binding’s pom.xml:

  <properties>
    <bnd.importpackage>javax.measure.*;version="[2.1,3)"</bnd.importpackage>
  </properties>

Don’t check in this change. It’s just for your local build / test purposes, to make the jar compatible with openhab 4.0.x

1 Like

Thank you. That worked. Can you explain the proper way to setup Eclipse and the distro such that it compiles for the 4.0.x version I’m running? Or better yet, can I force Maven to compile the jar for both the latest snapshot version and the last release version? Similar to this mvn switch to compile for OH3.4.0.

mvn clean install -pl :org.openhab.binding.haywardomnilogic -Dohc.version=3.4.0 -Doh.java.version=11 -Dkaraf.version=4.3.7

This is above my pay grade! :slight_smile: Firstly I don’t use Eclipse, but more importantly, and someone might correct me here, but I don’t think you can compile for both the latest snapshot version and the last release version that easily. There are some dependencies that have changed / upgraded, like you found out with javax.measure. But there may be classes that are refactored / removed / added which can make it complicated. It’s not very often though, so simple workarounds like what I posted above is enough for me. Most of the time, it works without having to do anything special. Maybe there’s a better way, but I don’t know.

The most surefire way to do it is by applying your code to both the main branch and the 4.0.x branch and compile them separately.

I have the same problem and this hack doesn’t seem to work for me…

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.