Problem with Lib after Migration to Maven + Bnd based build system

Hello,

I tried to change my binding to the Maven + Bnd based build system with this Tutorial:

But I have problems with my used library https://github.com/hypfvieh/dbus-java
If I read the docs I assume that I only have to add the dependency in pom.xml.

<dependencies>
<dependency>
<groupId>com.github.hypfvieh</groupId>
<artifactId>dbus-java</artifactId>
<version>3.2.0</version>
<scope>provided</scope>
</dependency>
</dependencies>

and in feature.xml:
<bundle dependency="true">mvn:com.github.hypfvieh/dbus-java/3.2.0</bundle>

But I get the Error “Unable to create resource for bundle mvn:com.github.hypfvieh/dbus-java/3.2.0”

Here the Error-Log:
https://pastebin.com/uXCscNZq

It looks like that dependency is not an OSGi bundle. (N.B. In the docs “If the bundle is not an OSGi-bundle, you need to wrap it and provide proper names”)

Try this instead in feature.xml:

<bundle dependency="true">wrap:mvn:com.github.hypfvieh/dbus-java/3.2.0$Bundle-Name=hypfvieh%20dbus-java%20Library&amp;Bundle-SymbolicName=com.github.hypfvieh.dbusjava&amp;Bundle-Version=3.2.0</bundle>

The documentation is out of date. I‘ll update it this evening.

2 Likes

Funny. I already wrote that part in 09/19 but forgot to create a PR for it. You can find the correct documentation here:

1 Like

Thanks for the fast response!

I’ve tried your proposals. But not very sucessfully, yet.

@J-N-K if I understand your new documentation correct, it is enough to define my dependency in POM.xml
So now in my pom.xml is the following dependency:

<dependencies>
  <dependency>
    <groupId>com.github.hypfvieh</groupId>
    <artifactId>dbus-java</artifactId>
    <version>3.2.0</version>
    <scope>compile</scope>
  </dependency>
</dependencies>

Here my Output of “mvn clean install -e”
https://pastebin.com/WyVEWuDb

@rossgb Thanks for your answer! But also with “wrap” in feature.xml not successfully.

org.apache.felix.resolver.reason.ReasonException: Unable to resolve root: missing requirement [root] osgi.identity; osgi.identity=openhab-binding-victronenergydbus; type=karaf.feature; version=2.5.4.SNAPSHOT; filter:="(&(osgi.identity=openhab-binding-victronenergydbus)(type=karaf.feature)(version>=2.5.4.SNAPSHOT))" [caused by: Unable to resolve openhab-binding-victronenergydbus/2.5.4.SNAPSHOT: missing requirement [openhab-binding-victronenergydbus/2.5.4.SNAPSHOT] osgi.identity; osgi.identity=org.openhab.binding.victronenergydbus; type=osgi.bundle; version="[2.5.4.202004202016,2.5.4.202004202016]"; resolution:=mandatory [caused by: Unable to resolve org.openhab.binding.victronenergydbus/2.5.4.202004202016: missing requirement [org.openhab.binding.victronenergydbus/2.5.4.202004202016] osgi.wiring.package; filter:="(osgi.wiring.package=com.github.hypfvieh.threads)"]]

Looks like you are missing a bundle that exports com.github.hypfvieh.threads. Maybe that is a dependency of your dependency?

1 Like

What does your feature look like? Please open a PR with WIP-prefix, it‘s much easier to help you if I can look at the whole code.

OK, thanks!
You was right. Java-Util was also missing as an dependency.

But there is still another Error and I’m stuck.
There is a missing Package com.sun.security.auth.module
But I have no idea which code needs this lib!?

[ERROR] Failed to execute goal org.apache.karaf.tooling:karaf-maven-plugin:4.2.7:verify (karaf-feature-verification) on project org.openhab.binding.victronenergydbus: Feature resolution failed for [openhab-binding-victronenergydbus/2.5.4.SNAPSHOT]
[ERROR] Message: Unable to resolve root: missing requirement [root] osgi.identity; osgi.identity=openhab-binding-victronenergydbus; type=karaf.feature; version=2.5.4.SNAPSHOT; filter:="(&(osgi.identity=openhab-binding-victronenergydbus)(type=karaf.feature)(version>=2.5.4.SNAPSHOT))" [caused by: Unable to resolve openhab-binding-victronenergydbus/2.5.4.SNAPSHOT: missing requirement [openhab-binding-victronenergydbus/2.5.4.SNAPSHOT] osgi.identity; osgi.identity=org.openhab.binding.victronenergydbus; type=osgi.bundle; version="[2.5.4.202004211645,2.5.4.202004211645]"; resolution:=mandatory [caused by: Unable to resolve org.openhab.binding.victronenergydbus/2.5.4.202004211645: missing requirement [org.openhab.binding.victronenergydbus/2.5.4.202004211645] osgi.wiring.package; filter:="(osgi.wiring.package=com.sun.security.auth.module)"]]

Any idea how to fix also this Error?

Good Idea to share my cloned github.

I can’t test your bundle, but I guess you don’t need that package. Try adding

  <properties>
    <bnd.importpackage>com.sun.security.auth.module;resolution:=optional</bnd.importpackage>
  </properties>

to the pom.xml. This at least compiles, you need to check if the functionality is still present with this change.

1 Like

Thank you very much @J-N-K
I added this lines to my pom.xml an have no Problems with the Binding.
But I still have no idea where I can find this dependency in my code!?

It‘s not directly in your code. It‘s a dependency of one of your dependencies. dbus-java depends on jnr-unixsockets which again has some dependencies. I guess somewhere something imports these packages. If you don‘t actively use that classes, you‘ll never notice it‘s not there. That‘s why I suggested to make it optional.

1 Like