openHAB3 addon: resolution failed, requirements not found for non OSGi dependencies

Hi openHAB Community,

I am developing a binding simply called opcua for openHAB 3 which uses OPCUA as protocol.
For supporting this protocol, my binding relies on eclipse milo (github) which is also published to maven central.

The dependency tree of my binding looks like this (leaving out openhab dependencies and bundles):

  org.openhab.addons.bundles:org.openhab.binding.opcua:jar:3.4.0-SNAPSHOT
  +- org.eclipse.milo:sdk-client:jar:0.6.7:compile
  |  +- org.eclipse.milo:stack-client:jar:0.6.7:compile
  |  |  +- org.eclipse.milo:stack-core:jar:0.6.7:compile
  |  |  |  +- org.bouncycastle:bcprov-jdk15on:jar:1.69:compile
  |  |  |  +- com.google.guava:guava:jar:31.0.1-jre:compile
  |  |  |  |  +- com.google.guava:failureaccess:jar:1.0.1:compile
  |  |  |  |  \- com.google.guava:listenablefuture:jar:9999.0-empty-to-avoid-conflict-with-guava:compile
  |  |  |  \- org.glassfish.jaxb:jaxb-runtime:jar:2.3.6:compile
  |  |  |  +- org.glassfish.jaxb:txw2:jar:2.3.6:compile
  |  |  |  \- com.sun.istack:istack-commons-runtime:jar:3.0.12:compile
  |  |  +- com.digitalpetri.netty:netty-channel-fsm:jar:0.8:compile
  |  |  |  \- com.digitalpetri.fsm:strict-machine:jar:0.6:compile
  |  |  \- io.netty:netty-codec-http:jar:4.1.77.Final:compile
  |  \- org.eclipse.milo:sdk-core:jar:0.6.7:compile

The binding was created using the official skeleton script present in the addon git repository.
Adding the dependency as defined in the tutorials on the openHAB developer pages does however yield errors when trying to resolve the requirements:

Resolution failed. Capabilities satisfying the following requirements could not be found:
    [<<INITIAL>>]
      ⇒ osgi.identity: (osgi.identity=org.openhab.binding.opcua)
          ⇒ [org.openhab.binding.opcua version=3.4.0.202207270859]
              ⇒ osgi.wiring.package: (osgi.wiring.package=com.digitalpetri.netty.fsm)
    [org.apache.karaf.kar.core version=4.3.7]
      ⇒ osgi.service: (objectClass=org.apache.karaf.features.FeaturesService)

Troubleshooting so far

The binding only has a single depedency added to the pom of the opcua binding:


	<artifactId>org.openhab.binding.opcua</artifactId>
	...
	
    <dependencies>
        <dependency>
            <groupId>org.eclipse.milo</groupId>
            <artifactId>sdk-client</artifactId>
            <version>0.6.7</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>
	
	...

The binding itself is correctly added into the addons project (included in both addons/pom.xml as well as bundles/pom.xml).
The package bnd tries to import is not an osgi bundle!
Any misconfiguration with the setup can be ruled out as it is a clean setup with eclipse and jdk11 (zulu).
Running openHAB with the bundle opcua works without any issues if the dependency is removed together with the code that calls/relies on it!

Wrapping the dependency with wrap:mvn:org.eclipse.milo and adding it in the features of the bundle does result in errors.

Interestingly enough is that, excluding the transistive dependency which throws the error only resolves to additional errors about netty not being resolved.
So my guess is that it is a resolver error, not a package error?!

Unresolved requirement: Import-Package: io.netty.buffer; version="[4.1.0,5.0.0)

Have I missed any necessary configuration steps in openHAB itself or the bundle to resolve transitive non OSGi depdendencies in my bundle?!
How can I resolve the errors and help the bnd plugin pulling the dependencies into the bundle?

Thanks,
Gernot

netty is part of the dependency tree shown above. So you have to exclude it if you don’t need it (is that really the case?). You can do that by something like

  <properties>
    <bnd.importpackage>io.netty.*;resolution="optional"</bnd.importpackage>
  </properties>

Thanks for the feedback. I need the netty dependency in the project. The problem is however that non of the dependencies shown in the tree can be resolved.

So the problem comes down to: transistive non-OSGi dependencies cannot be resolved.
If it helps for resolving this issue, I can provide the barebone skeleton as a github project.

If you need netty and JAXB, they can be fulfilled by core features:

<feature>openhab.tp-netty</feature>           
<requirement>openhab.tp;filter:="(feature=jaxb)"</requirement>
<feature dependency="true">openhab.tp-jaxb</feature>

The other dependencies can be added with scope compile to the POM, then they’ll be embedded in the binding bundle. Do you intend to publish your binding under an open source license?

I think that requirement statement and dependency on jaxb is unnecessary. :wink:

I agree. But when I originally provided the code this is taken from, it was requested to add that for clarity.

Yes, the opcua binding is currently developed with only open source solutions to make it possible to be open sourced (after clarification from legal). If it won’ work with eclipse milo as opcua library, a proprietary solution will be used, but then cannot be made open source.

Hi Community,

So a little update, i fixed the problem with a work around by copying the complete source code of most of my dependencies into the binding itself. None of the other provided solutions worked in my case.
Any NoClassDefFound Errors it gave me afterwards were easily fixed by adding additional dependencies.

So now my project has 879 source files for the binding, compiles and runs smoothly
(Only logging is always visible in the karaf console and cannot be controlled with settings).

My question is whether it is against the openhab guidelines to opensource it, since some of the projects I had to put in as source use the Apache License 2.0 not the Eclipse Public License 2.0.

Thanks for the help in advance,
Gernot

I have feature set for this dependency working. I also got binding implemented in a basic form.

See: connectorio-addons/bundles/org.connectorio.addons.binding.opcua at 3.3.x · ConnectorIO/connectorio-addons · GitHub.

Checkout 3.3.x branch and do mvn clean install -pl :org.connectorio.addons.kar.opcua -am.

Hi Lukasz,

I first tested your opcua binding by building and then trying to run it on my local setup.
OpenHAB had trouble downloading the required dependencies (guava jre 31.0.1 for example) which i fixed by setting org.ops4j.pax.url.mvn.defaultLocalRepoAsRemote = true in the org.ops4j.pax.url.mvn.cfg file in then userdata/etc/ directory.

Applying the featureset from feature-set-opcua actually fixed the problem.

Thank you for your help,
Gernot

@ggessner have you tried copying over kars/org.connectorio.addons.kar.opcua/target/org.connectorio.addons.kar.opcua-*.kar into addons folder? I think it should work with offline/openhab installation.