Need help with (transitive) dependency in my PR

Background

My SmartMeter PR has a dependency on the JDLMS library org.openmuc.jdlms with further transitive dependencies on org.openmuc.jrxtx, com.beanit.asn1bean, and org.bouncycastle.crypto.

I have figured out how to get Maven to build the addon; including dependency entries in feature.xml and pom.xml ..

feature.xml
	<feature name="openhab-binding-smartmeter" description="Smartmeter Binding" version="${project.version}">
		<feature>openhab-runtime-base</feature>
		<feature>openhab-transport-serial</feature>
		<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.smartmeter/${project.version}</bundle>
		<bundle dependency="true">mvn:org.openmuc/jdlms/1.8.0</bundle>
		<bundle dependency="true">mvn:com.beanit/asn1bean/1.14.0</bundle>
		<bundle dependency="true">mvn:org.openmuc/jrxtx/1.0.1</bundle>
		<bundle dependency="true">mvn:org.bouncycastle/bcprov-jdk18on/1.81</bundle>
	</feature>
pom.xml
 <dependencies>
    <dependency>
      <groupId>io.reactivex.rxjava2</groupId>
      <artifactId>rxjava</artifactId>
      <version>2.2.21</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.reactivestreams</groupId>
      <artifactId>reactive-streams</artifactId>
      <version>1.0.4</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.openmuc</groupId>
      <artifactId>jsml</artifactId>
      <version>1.1.2</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.openmuc</groupId>
      <artifactId>j62056</artifactId>
      <version>2.2.0</version>
      <scope>compile</scope>
      <exclusions>
        <exclusion>
          <groupId>org.openmuc</groupId>
          <artifactId>jrxtx</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.openmuc</groupId>
      <artifactId>jdlms</artifactId>
      <version>1.8.0</version>
    </dependency>
    <dependency>
      <groupId>com.beanit</groupId>
      <artifactId>asn1bean</artifactId>
      <version>1.14.0</version>
    </dependency>
    <dependency>
      <groupId>org.openmuc</groupId>
      <artifactId>jrxtx</artifactId>
      <version>1.0.1</version>
    </dependency>
  </dependencies>

Problem

My problem is that when I try to load the addon Jar (in an OH 5.1.x snapshot system) I get the log message below. I have been playing with this for too many hours now, so I am probably missing something obvious, but can someone please let me know how I can resolve the missing requirement?

2025-08-11 14:22:14.450 [WARN ] [org.apache.felix.fileinstall        ] - Error while starting bundle: file:/usr/share/openhab/addons/org.openhab.binding.smartmeter-5.1.0-SNAPSHOT.jar
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.smartmeter [266]
  Unresolved requirement: Import-Package: org.bouncycastle.crypto; version="[1.81.0,2.0.0)"

That will only work if you first manually install all the bundle dependencies of your feature. Instead you can create a KAR file (which includes all dependencies) or embed all these dependencies in your add-on bundle.

1 Like

I never managed to get a kar working so I download the dependency jar’s and drop them in the addon folder.