Hi, I have been developping a binding for merossIOT. The bundle archetype runs properly.
Then I add following binding pom file:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.addons.reactor.bundles</artifactId>
<version>4.3.0-SNAPSHOT</version>
</parent>
<artifactId>org.openhab.binding.meross</artifactId>
<name>openHAB Add-ons :: Bundles :: Meross Binding</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>5.1.9</version>
<executions>
<execution>
<id>bundle-manifest</id>
<phase>process-classes</phase>
<goals>
<goal>manifest</goal>
</goals>
</execution>
</executions>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Import-Package>org.meross4j.*</Import-Package>
<Embed-Transitive>true</Embed-Transitive>
<Bundle-Version>$(replace;$(project.version);"").$(tstamp;yyyyMMdd-HHmm)</Bundle-Version>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.meross4j</groupId>
<artifactId>meross4j</artifactId>
<version>0.2.8</version>
</dependency>
</dependencies>
</project>
As you can see I have a dependency on meross4j, so I do a Import-Package istruction on that, together with Embed-Transitive.
Here is the meross4j library pom file:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.meross4j</groupId>
<artifactId>meross4j</artifactId>
<version>0.2.8</version>
<name>meross4j Meross Java library</name>
<description>meross4j is a Java library for the Meross cloud</description>
<distributionManagement>
<repository>
<id>github</id>
<name>GitHub Packages</name>
<url>https://maven.pkg.github.com/fabgio/meross4j</url>
</repository>
</distributionManagement>
<licenses>
<license>
<name>Eclipse Public License 2.0</name>
<url>https://www.eclipse.org/legal/epl-2.0</url>
<distribution>repo</distribution>
</license>
</licenses>
<developers>
<developer>
<id>fabgio</id>
<name>Giovanni Fabiani</name>
<roles>
<role>developer</role>
</roles>
<timezone>Europe/Rome</timezone>
</developer>
</developers>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.10.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.10.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.23.1</version>
</dependency>
<dependency>
<groupId>com.hivemq</groupId>
<artifactId>hivemq-mqtt-client</artifactId>
<version>1.3.3</version>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>6.0.0</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>maven_central</id>
<name>Maven Central</name>
<url>https://repo.maven.apache.org/maven2/</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>attach-sources</id>
<phase>verify</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.6.3</version>
<configuration>
<javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
<release>17</release>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>5.1.9</version>
<executions>
<execution>
<id>bundle-manifest</id>
<phase>process-classes</phase>
<goals>
<goal>manifest</goal>
</goals>
</execution>
</executions>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Activator>org.meross4j.bundle.Activator</Bundle-Activator>
<Export-Package>org.meross4j.*</Export-Package>
<Bundle-Version>$(replace;$(project.version);"").$(tstamp;yyyyMMdd-HHmm)</Bundle-Version>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>
Here is the output of karaf’s bundle:headers command
openHAB Add-ons :: Bundles :: Meross Binding (285)
--------------------------------------------------
Automatic-Module-Name = org.openhab.binding.meross
Bnd-LastModified = 1730133945046
Build-Jdk-Spec = 17
Created-By = Apache Maven Bundle Plugin 5.1.9
Embed-Transitive = true
Manifest-Version = 1.0
Originally-Created-By = 17.0.13 (Azul Systems, Inc.)
Service-Component = OSGI-INF/org.openhab.binding.meross.internal.MerossHandlerFactory.xml,OSGI-INF/org.openhab.binding.meross.internal.MerossHandlerFactory.xml
Tool = Bnd-6.3.1.202206071316
Bundle-Description = This project contains the official add-ons of openHAB
Bundle-Developers = openhab;email="info@openhab.org";name=openHAB;organization=openHAB;organizationUrl="https://www.openHAB.org"
Bundle-DocURL = https://www.openhab.org
Bundle-License = https://www.eclipse.org/legal/epl-2.0/
Bundle-ManifestVersion = 2
Bundle-Name = openHAB Add-ons :: Bundles :: Meross Binding
Bundle-SCM = url="https://github.com/openhab/openhab-addons/org.openhab.addons.reactor.bundles/org.openhab.binding.meross",connection="scm:git:https://github.com/openhab/openhab-addons.git/org.openhab.addons.reactor.bundles/org.openhab.binding.meross",developer-connection="scm:git:https://github.com/openhab/openhab-addons.git/org.openhab.addons.reactor.bundles/org.openhab.binding.meross",tag=HEAD
Bundle-SymbolicName = org.openhab.binding.meross
Bundle-Vendor = openHAB.org
Bundle-Version = 4.3.0.SNAPSHOT20241028-1645
Provide-Capability =
osgi.service;
uses:=org.openhab.core.thing.binding;
objectClass:List<String>=org.openhab.core.thing.binding.ThingHandlerFactory
Require-Capability =
osgi.extender;filter:=(&(osgi.extender=osgi.component)(version>=1.5.0)(!(version>=2.0.0))),
osgi.ee;filter:=(&(osgi.ee=JavaSE)(version=17)),
osgi.extender;filter:=(&(osgi.extender=osgi.component)(version>=1.5.0)(!(version>=2.0.0)))
Export-Package =
org.meross4j.bundle;version=0.2.8,
org.meross4j.command;version=0.2.8,
org.meross4j.communication;uses:=org.meross4j.record;version=0.2.8,
org.meross4j.factory;uses:=org.meross4j.command;version=0.2.8,
org.meross4j.record;version=0.2.8,
org.meross4j.util;version=0.2.8
Import-Package =
org.meross4j.command;version="[0.2,1)",
org.meross4j.communication;version="[0.2,1)",
org.meross4j.factory;version="[0.2,1)",
org.meross4j.record;version="[0.2,1)",
org.meross4j.util;version="[0.2,1)"
Karaf shows the binding is active
Then when the Handler starts I have got a NoClassDefFound on ThingHandlerFactory class; clearly meaning that one dependency the class depends on is missing (OSGi in action book); so obviously the HandlerFactory service cannot start! How can I make ThingHanderFactory service visible again?