How to add my own external library to a Binding

Tags: #<Tag:0x00007f616e821708> #<Tag:0x00007f616e821500>

Hello community.
I am developing an external library, where I concentrate all the logic I need. The idea is to have that logic concentrated, and that it can be used in different projects. One of these projects is an Openhab Binding. What would be the correct way (or at least one that works) to add this library in the Binding?

Here is the documentation. It’s not completely up-to-date, but should give an idea. You can also check other bindings. Also check if the library you add doesn’t have similar functionality as libraries already supported, because if so you will run into problems getting the binding added to openHAB in case you plan to add it.

1 Like

Hello! Thank you very much for the quick answer. I was working following the documentation, but I got an error. I am using the second variant discussed in the documentation “** Internal dependency **”. This is the sequence of steps I did:

  • Create new binding using “create_openhab_binding_skeleton”

  • mvn clean

  • Create folder / lib

  • Copy my JAR library to / lib

  • mvn install

  • I receive this error:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 03:19 min
[INFO] Finished at: 2020-06-10T15:16:59-04:00
[INFO] ------------------------------------------------------------------------
[INFO] Static code analysis summary report is available in:
[INFO] file:/C:/Users/admin/me/development/openhab-addons/openhab-addons/bundles/org.openhab.binding.mybinding/target/summary_report.html
[ERROR] Failed to execute goal org.apache.karaf.tooling:karaf-maven-plugin:4.2.7:verify (karaf-feature-verification) on project org.openhab.binding.mybinding: Feature resolution failed for [openhab-binding-mybinding/2.5.5.SNAPSHOT]
[ERROR] Message: Unable to resolve root: missing requirement [root] osgi.identity; osgi.identity=openhab-binding-mybinding; type=karaf.feature; version=2.5.5.SNAPSHOT; filter:="(&(osgi.identity=openhab-binding-mybinding)(type=karaf.feature)(version>=2.5.5.SNAPSHOT))" [caused by: Unable to resolve openhab-binding-mybinding/2.5.5.SNAPSHOT: missing requirement [openhab-binding-mybinding/2.5.5.SNAPSHOT] osgi.identity; osgi.identity=org.openhab.binding.mybinding; type=osgi.bundle; version="[2.5.5.202006101915,2.5.5.202006101915]"; resolution:=mandatory [caused by: Unable to resolve org.openhab.binding.mybinding/2.5.5.202006101915: missing requirement [org.openhab.binding.mybinding/2.5.5.202006101915] osgi.wiring.package; filter:="(osgi.wiring.package=com.google.protobuf)"]]
[ERROR] Repositories: {
[ERROR] file:C:\Users\admin\me\development\openhab-addons\openhab-addons\bundles\org.openhab.binding.mybinding\target/feature/feature.xml
[ERROR] mvn:org.apache.karaf.features/framework/4.2.7/xml/features
[ERROR] mvn:org.apache.karaf.features/standard/4.2.7/xml/features
[ERROR] mvn:org.openhab.core.features.karaf/org.openhab.core.features.karaf.openhab-core/2.5.0/xml/features
[ERROR] mvn:org.openhab.core.features.karaf/org.openhab.core.features.karaf.openhab-tp/2.5.0/xml/features
[ERROR] mvn:org.ops4j.pax.web/pax-web-features/7.2.11/xml/features
[ERROR] }
[ERROR] Resources: {
[ERROR] mvn:com.eclipsesource.jaxrs/publisher/5.3.1
[ERROR] mvn:com.google.guava/failureaccess/1.0.1
[ERROR] mvn:com.google.guava/guava/18.0
[ERROR] mvn:com.google.guava/guava/27.1-jre
[ERROR] mvn:commons-codec/commons-codec/1.6
[ERROR] mvn:commons-collections/commons-collections/3.2.1
[ERROR] mvn:commons-io/commons-io/2.2
[ERROR] mvn:commons-lang/commons-lang/2.6
[ERROR] mvn:commons-net/commons-net/3.3
[ERROR] mvn:de.jollyday/jollyday/0.5.8
[ERROR] mvn:de.maggu2810.p2redist/com.google.inject/3.0.0.v201312141243
[ERROR] mvn:de.maggu2810.p2redist/org.antlr.runtime/3.2.0.v201101311130
[ERROR] mvn:javax.annotation/javax.annotation-api/1.2
[ERROR] mvn:javax.annotation/javax.annotation-api/1.3
[ERROR] mvn:javax.el/javax.el-api/3.0.0
[ERROR] mvn:javax.mail/mail/1.4.7
[ERROR] mvn:javax.measure/unit-api/1.0
[ERROR] mvn:javax.servlet/javax.servlet-api/3.1.0
[ERROR] mvn:javax.validation/validation-api/1.1.0.Final
[ERROR] mvn:javax.websocket/javax.websocket-api/1.1
[ERROR] mvn:javax.ws.rs/javax.ws.rs-api/2.0.1
[ERROR] mvn:joda-time/joda-time/2.9.2
[ERROR] mvn:org.apache.aries.spifly/org.apache.aries.spifly.dynamic.bundle/1.2
[ERROR] mvn:org.apache.aries/org.apache.aries.util/1.1.3
[ERROR] mvn:org.apache.commons/commons-exec/1.1
[ERROR] mvn:org.apache.felix/org.apache.felix.configadmin/1.9.16
[ERROR] mvn:org.apache.felix/org.apache.felix.coordinator/1.0.2
[ERROR] mvn:org.apache.felix/org.apache.felix.fileinstall/3.6.4
[ERROR] mvn:org.apache.felix/org.apache.felix.inventory/1.0.4
[ERROR] mvn:org.apache.felix/org.apache.felix.metatype/1.2.2
[ERROR] mvn:org.apache.felix/org.apache.felix.scr/2.1.16
[ERROR] mvn:org.apache.felix/org.apache.felix.webconsole.plugins.ds/2.1.0
[ERROR] mvn:org.apache.felix/org.apache.felix.webconsole.plugins.event/1.1.8
[ERROR] mvn:org.apache.geronimo.specs/geronimo-jaspic_1.0_spec/1.1
[ERROR] mvn:org.apache.geronimo.specs/geronimo-jta_1.1_spec/1.1.1
[ERROR] mvn:org.apache.karaf.features/org.apache.karaf.features.core/4.2.7
[ERROR] mvn:org.apache.karaf.features/org.apache.karaf.features.extension/4.2.7
[ERROR] mvn:org.apache.karaf.http/org.apache.karaf.http.core/4.2.7
[ERROR] mvn:org.apache.karaf.jaas/org.apache.karaf.jaas.boot/4.2.7
[ERROR] mvn:org.apache.karaf.scr/org.apache.karaf.scr.management/4.2.7
[ERROR] mvn:org.apache.karaf.scr/org.apache.karaf.scr.state/4.2.7
[ERROR] mvn:org.apache.karaf.services/org.apache.karaf.services.eventadmin/4.2.7
[ERROR] mvn:org.apache.karaf.shell/org.apache.karaf.shell.commands/4.2.7
[ERROR] mvn:org.apache.karaf.shell/org.apache.karaf.shell.core/4.2.7
[ERROR] mvn:org.apache.karaf.webconsole/org.apache.karaf.webconsole.http/4.2.7
[ERROR] mvn:org.apache.karaf.wrapper/org.apache.karaf.wrapper.core/4.2.7
[ERROR] mvn:org.apache.karaf/org.apache.karaf.event/4.2.7
[ERROR] mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.javax-inject/1_2
[ERROR] mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.xstream/1.4.7_1
[ERROR] mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.activation-api-1.1/2.9.0
[ERROR] mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.jaxb-api-2.2/2.9.0
[ERROR] mvn:org.apache.xbean/xbean-bundleutils/4.14
[ERROR] mvn:org.apache.xbean/xbean-finder/4.14
[ERROR] mvn:org.apache.xbean/xbean-reflect/4.14
[ERROR] mvn:org.eclipse.emf/org.eclipse.emf.common/2.12.0
[ERROR] mvn:org.eclipse.emf/org.eclipse.emf.ecore.change/2.11.0
[ERROR] mvn:org.eclipse.emf/org.eclipse.emf.ecore.xmi/2.12.0
[ERROR] mvn:org.eclipse.emf/org.eclipse.emf.ecore/2.12.0
[ERROR] mvn:org.eclipse.jdt.core.compiler/ecj/4.5.1
[ERROR] mvn:org.eclipse.jetty.websocket/javax-websocket-client-impl/9.4.20.v20190813
[ERROR] mvn:org.eclipse.jetty.websocket/javax-websocket-server-impl/9.4.20.v20190813
[ERROR] mvn:org.eclipse.jetty.websocket/websocket-api/9.4.20.v20190813
[ERROR] mvn:org.eclipse.jetty.websocket/websocket-client/9.4.20.v20190813
[ERROR] mvn:org.eclipse.jetty.websocket/websocket-common/9.4.20.v20190813
[ERROR] mvn:org.eclipse.jetty.websocket/websocket-server/9.4.20.v20190813
[ERROR] mvn:org.eclipse.jetty.websocket/websocket-servlet/9.4.20.v20190813
[ERROR] mvn:org.eclipse.jetty/jetty-client/9.4.20.v20190813
[ERROR] mvn:org.eclipse.jetty/jetty-continuation/9.4.20.v20190813
[ERROR] mvn:org.eclipse.jetty/jetty-deploy/9.4.20.v20190813
[ERROR] mvn:org.eclipse.jetty/jetty-http/9.4.20.v20190813
[ERROR] mvn:org.eclipse.jetty/jetty-io/9.4.20.v20190813
[ERROR] mvn:org.eclipse.jetty/jetty-jaas/9.4.20.v20190813
[ERROR] mvn:org.eclipse.jetty/jetty-jaspi/9.4.20.v20190813
[ERROR] mvn:org.eclipse.jetty/jetty-jmx/9.4.20.v20190813
[ERROR] mvn:org.eclipse.jetty/jetty-jndi/9.4.20.v20190813
[ERROR] mvn:org.eclipse.jetty/jetty-plus/9.4.20.v20190813
[ERROR] mvn:org.eclipse.jetty/jetty-proxy/9.4.20.v20190813
[ERROR] mvn:org.eclipse.jetty/jetty-rewrite/9.4.20.v20190813
[ERROR] mvn:org.eclipse.jetty/jetty-security/9.4.20.v20190813
[ERROR] mvn:org.eclipse.jetty/jetty-server/9.4.20.v20190813
[ERROR] mvn:org.eclipse.jetty/jetty-servlet/9.4.20.v20190813
[ERROR] mvn:org.eclipse.jetty/jetty-servlets/9.4.20.v20190813
[ERROR] mvn:org.eclipse.jetty/jetty-util-ajax/9.4.20.v20190813
[ERROR] mvn:org.eclipse.jetty/jetty-util/9.4.20.v20190813
[ERROR] mvn:org.eclipse.jetty/jetty-webapp/9.4.20.v20190813
[ERROR] mvn:org.eclipse.jetty/jetty-xml/9.4.20.v20190813
[ERROR] mvn:org.eclipse.lsp4j/org.eclipse.lsp4j.jsonrpc/0.8.0
[ERROR] mvn:org.eclipse.lsp4j/org.eclipse.lsp4j/0.8.0
[ERROR] mvn:org.eclipse.orbit.bundles/com.google.gson/2.8.2.v20180104-1110
[ERROR] mvn:org.eclipse.orbit.bundles/io.github.classgraph/4.8.35.v20190528-1517
[ERROR] mvn:org.eclipse.platform/org.eclipse.equinox.common/3.10.400
[ERROR] mvn:org.eclipse.platform/org.eclipse.equinox.registry/3.8.400
[ERROR] mvn:org.eclipse.platform/org.eclipse.equinox.supplement/1.9.0
[ERROR] mvn:org.eclipse.xtend/org.eclipse.xtend.lib.macro/2.19.0
[ERROR] mvn:org.eclipse.xtend/org.eclipse.xtend.lib/2.19.0
[ERROR] mvn:org.eclipse.xtext/org.eclipse.xtext.common.types/2.19.0
[ERROR] mvn:org.eclipse.xtext/org.eclipse.xtext.ide/2.19.0
[ERROR] mvn:org.eclipse.xtext/org.eclipse.xtext.smap/2.19.0
[ERROR] mvn:org.eclipse.xtext/org.eclipse.xtext.util/2.19.0
[ERROR] mvn:org.eclipse.xtext/org.eclipse.xtext.xbase.ide/2.19.0
[ERROR] mvn:org.eclipse.xtext/org.eclipse.xtext.xbase.lib/2.19.0
[ERROR] mvn:org.eclipse.xtext/org.eclipse.xtext.xbase/2.19.0
[ERROR] mvn:org.eclipse.xtext/org.eclipse.xtext/2.19.0
[ERROR] mvn:org.fusesource.jansi/jansi/1.18
[ERROR] mvn:org.glassfish.hk2.external/aopalliance-repackaged/2.4.0-b34
[ERROR] mvn:org.glassfish.hk2.external/javax.inject/2.4.0-b34
[ERROR] mvn:org.glassfish.hk2/hk2-api/2.4.0-b34
[ERROR] mvn:org.glassfish.hk2/hk2-locator/2.4.0-b34
[ERROR] mvn:org.glassfish.hk2/hk2-utils/2.4.0-b34
[ERROR] mvn:org.glassfish.hk2/osgi-resource-locator/1.0.1
[ERROR] mvn:org.glassfish.jersey.bundles.repackaged/jersey-guava/2.22.2
[ERROR] mvn:org.glassfish.jersey.containers/jersey-container-servlet-core/2.22.2
[ERROR] mvn:org.glassfish.jersey.containers/jersey-container-servlet/2.22.2
[ERROR] mvn:org.glassfish.jersey.core/jersey-client/2.22.2
[ERROR] mvn:org.glassfish.jersey.core/jersey-common/2.22.2
[ERROR] mvn:org.glassfish.jersey.core/jersey-server/2.22.2
[ERROR] mvn:org.glassfish.jersey.media/jersey-media-jaxb/2.22.2
[ERROR] mvn:org.glassfish.jersey.media/jersey-media-multipart/2.22.2
[ERROR] mvn:org.glassfish.jersey.media/jersey-media-sse/2.22.2
[ERROR] mvn:org.javassist/javassist/3.18.1-GA
[ERROR] mvn:org.jline/jline-builtins/3.12.1
[ERROR] mvn:org.jline/jline-reader/3.12.1
[ERROR] mvn:org.jline/jline-terminal-jansi/3.12.1
[ERROR] mvn:org.jline/jline-terminal/3.12.1
[ERROR] mvn:org.jmdns/jmdns/3.5.5
[ERROR] mvn:org.jvnet.mimepull/mimepull/1.9.6
[ERROR] mvn:org.mapdb/mapdb/1.0.9
[ERROR] mvn:org.openhab.addons.bundles/org.openhab.binding.mybinding/2.5.5-SNAPSHOT
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.audio/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.auth.oauth2client/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.binding.xml/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.boot/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.config.core/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.config.discovery.mdns/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.config.discovery/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.config.dispatch/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.config.xml/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.ephemeris/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.id/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.io.console.karaf/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.io.console/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.io.http/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.io.jetty.certificate/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.io.monitor/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.io.net/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.io.rest.audio/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.io.rest.core/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.io.rest.mdns/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.io.rest.optimize/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.io.rest.sitemap/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.io.rest.sse/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.io.rest.voice/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.io.rest/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.io.transport.mdns/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.karaf/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.model.core/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.model.item.ide/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.model.item.runtime/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.model.item/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.model.lsp/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.model.persistence.ide/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.model.persistence.runtime/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.model.persistence/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.model.rule.ide/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.model.rule.runtime/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.model.rule/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.model.script.ide/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.model.script.runtime/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.model.script/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.model.sitemap.ide/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.model.sitemap.runtime/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.model.sitemap/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.model.thing.ide/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.model.thing.runtime/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.model.thing/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.persistence/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.scheduler/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.semantics/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.storage.json/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.storage.mapdb/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.thing.xml/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.thing/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.transform/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.ui.icon/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.ui/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core.voice/2.5.0
[ERROR] mvn:org.openhab.core.bundles/org.openhab.core/2.5.0
[ERROR] mvn:org.ops4j.pax.logging/pax-logging-api/1.11.2
[ERROR] mvn:org.ops4j.pax.logging/pax-logging-log4j2/1.11.2
[ERROR] mvn:org.ops4j.pax.url/pax-url-aether/2.6.1
[ERROR] mvn:org.ops4j.pax.web/pax-web-api/7.2.11
[ERROR] mvn:org.ops4j.pax.web/pax-web-extender-whiteboard/7.2.11
[ERROR] mvn:org.ops4j.pax.web/pax-web-jetty/7.2.11
[ERROR] mvn:org.ops4j.pax.web/pax-web-jsp/7.2.11
[ERROR] mvn:org.ops4j.pax.web/pax-web-runtime/7.2.11
[ERROR] mvn:org.ops4j.pax.web/pax-web-spi/7.2.11
[ERROR] mvn:org.osgi/org.osgi.util.function/1.0.0
[ERROR] mvn:org.osgi/org.osgi.util.promise/1.0.0
[ERROR] mvn:org.ow2.asm/asm-analysis/7.1
[ERROR] mvn:org.ow2.asm/asm-commons/7.1
[ERROR] mvn:org.ow2.asm/asm-tree/7.1
[ERROR] mvn:org.ow2.asm/asm-util/7.1
[ERROR] mvn:org.ow2.asm/asm/7.1
[ERROR] mvn:org.threeten/threeten-extra/1.4
[ERROR] mvn:tec.uom.lib/uom-lib-common/1.0.3
[ERROR] mvn:tec.uom/uom-se/1.0.10
[ERROR] }

Any ideas that can help me or a step that I forget? Thank you!

This is the specific error message:

The last part of the message gives the problem. It needs to have all dependencies present otherwise it won’t work. This is not done via maven dependencies. In this case this library is also used by the chromecast binding. So check how it’s used in the pom.xml and feature.xml of that binding and copy what is used there (also see if you can use the same version).

(I didn’t add code fences otherwise it shows the error as 1 line.)

1 Like

Thank you @hilbrand !!! Thank you!!! Your advice was very helpful! My best greetings

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.