Hi, although I have been using openHAB for about 3 years until recently I had not coded in Java.
I am trying to develop a binding but have stumbled on an issue that has my stumped and was hoping for some help.
I have followed these guides:
Java:
java 17.0.10 2024-01-16 LTS
Java(TM) SE Runtime Environment (build 17.0.10+11-LTS-240)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.10+11-LTS-240, mixed mode, sharing)
And have an openHAB 4.0.4 development environment set up on a Windows 10 machine.
I took a copy of the openhab-addons about six weeks ago using:
git clone https://github.com/openhab/openhab-addons.git
and this is where my I have be writing my binding.
I am able to compile the binding and produce the .jar, but am unable to progress to testing as when I try to debug the binding, I get the following in the openHAB.log:
2024-03-10 16:55:02.618 [INFO ] [org.openhab.core.Activator ] - Starting openHAB 4.0.4 (build Release Build)
2024-03-10 16:55:03.594 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Time zone set to 'Europe/London'.
2024-03-10 16:55:03.607 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Location set to '51.03343985855335,-2.2592890262603764'.
2024-03-10 16:55:03.609 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Locale set to 'en_GB'.
2024-03-10 16:55:10.169 [WARN ] [org.openhab.core.net.NetUtil ] - Found multiple local interfaces - ignoring 192.168.1.197
2024-03-10 16:55:19.791 [INFO ] [.core.model.lsp.internal.ModelServer] - Started Language Server Protocol (LSP) service on port 5007
2024-03-10 16:55:24.433 [ERROR] [Events.Framework ] - FrameworkEvent ERROR
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.sunsynk [241]
Unresolved requirement: Import-Package: org.slf4j; version="[2.0.0,3.0.0)"
at org.eclipse.osgi.container.Module.start(Module.java:463) ~[org.eclipse.osgi-3.18.0.jar:?]
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1847) ~[org.eclipse.osgi-3.18.0.jar:?]
at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136) ~[org.eclipse.osgi-3.18.0.jar:?]
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1840) ~[org.eclipse.osgi-3.18.0.jar:?]
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1783) ~[org.eclipse.osgi-3.18.0.jar:?]
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1745) ~[org.eclipse.osgi-3.18.0.jar:?]
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1667) ~[org.eclipse.osgi-3.18.0.jar:?]
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) ~[org.eclipse.osgi-3.18.0.jar:?]
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234) ~[org.eclipse.osgi-3.18.0.jar:?]
at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345) ~[org.eclipse.osgi-3.18.0.jar:?]
I manged to resolve what feels like a similar problem by following this discussion: Problem dependencies
Similar problem was:
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.sunsynk [241]
Unresolved requirement: Import-Package: com.google.gson; version="[2.10.0,3.0.0)"
Resolution was to use the karaf console and install the missing dependency:
bundle:install https://repo1.maven.org/maven2/com/google/code/gson/gson/2.10/gson-2.10.jar
However I have not been able to fix:
Unresolved requirement: Import-Package: org.slf4j; version="[2.0.0,3.0.0)"
Having Googled around I have tried various things including this in Karaf console:
bundle:install https://repo1.maven.org/maven2/org/slf4j/slf4j-api/2.0.0/slf4j-api-2.0.0.jar
bundle:install https://repo1.maven.org/maven2/org/slf4j/osgi-over-slf4j/2.0.0/osgi-over-slf4j-2.0.0.jar
I have also rebuild one of the known working bindings in the cloned addons, but exactly the same issue when I try to debug.
Maybe I am missing something obvious?
To be honest my novice skills in Java maybe holding me back, not sure I fully understand dependency management, Maven and pom.xml well.
Any help appreciated.