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.