I am developing a next version of Danfoss binding and i am using a library, which has own set of dependencies:
org.openhab.binding.danfoss | +org.opensdg.java | + eu.neilalexander.jnacl + com.google.protobuf.protobuf-java
And i am struggling with building a deployable JAR. From what i know, when building a binding, all the dependencies, except those provided by the environment, are bundled in the JAR. At least direct ones.
Initially in my case opensdg was bundled in, but not jnacl and protobuf. I’ve used best of my google-fu and in a couple of hours i came up with my own maven-dependency-plugin configuration. Everything builds fine and i can run the result via app.bndrun.
But a drastic failure happened when i tried to deploy this JAR:
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.danfoss  Unresolved requirement: Import-Package: io.swagger.annotations; version="[1.5.0,2.0.0)"; resolution:="optional" Unresolved requirement: Import-Package: com.google.protobuf; version="[3.15.0,4.0.0)" at org.eclipse.osgi.container.Module.start(Module.java:444) ~[org.eclipse.osgi-3.12.100.jar:?] at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:383) ~[org.eclipse.osgi-3.12.100.jar:?] at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1260) [bundleFile:3.6.4] at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1233) [bundleFile:3.6.4] at org.apache.felix.fileinstall.internal.DirectoryWatcher.startAllBundles(DirectoryWatcher.java:1221) [bundleFile:3.6.4] at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:515) [bundleFile:3.6.4] at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:365) [bundleFile:3.6.4] at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:316) [bundleFile:3.6.4] 2021-07-28 01:55:33.877 [WARN ] [org.apache.felix.fileinstall ] - Error while starting bundle: file:/usr/share/openhab2/addons/org.openhab.binding.danfoss-2.5.9-SNAPSHOT.jar
What i am missing? I am examining manifest in META_INF/MANIFEST.MF and i see that the whole contents of opensdg is listed in “Private-Package:”, but opensdg’s dependencies are still in “Import-Package:” . What am i missing ? Or am i doing something badly wrong? I see that in .kar file, provided by OpenHAB, things are significantly different, and all the possible dependencies are not embedded in JARs but are placed in the KAR file.
Source codes are here:
Binding: GitHub - Sonic-Amiga/org.openhab.binding.devireg at opensdg-java
Library: GitHub - Sonic-Amiga/opensdg-java: Free and open SecureDeviceGrid protocol client side implementation in Java
Can anyone help ?