I’m working on developing a binding, mostly to learn how the system works and maybe learn how to implement some things and contribute to the community. So far I’ve been able to create the skeleton and get a binding that compiles to a .jar file. When I take the .jar file and put it in the addons folder of Openhab and restart eh system I get this error:
2018-03-28 15:31:15.751 [ERROR] [org.openhab.binding.insteonplmmatt ] - FrameworkEvent ERROR - org.openhab.binding.insteonplmmatt
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.insteonplmmatt 
Unresolved requirement: Import-Package: org.eclipse.jdt.annotation; resolution:="optional"
Unresolved requirement: Import-Package: org.eclipse.smarthome.core.util
at org.eclipse.osgi.container.Module.start(Module.java:444) [?:?]
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1620) [?:?]
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1599) [?:?]
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1571) [?:?]
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1514) [?:?]
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) [?:?]
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) [?:?]
at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340) [?:?]
I’ve been searching the forum and I’ve seen other people have had similar problems but I’m not understanding how to troubleshoot this issue. I’ve looked at the installed bundles and it looks like everything listed as “unresolved requirements” is listed as “Active” in the bundle list in my Openhab runtime. So I’m not sure what’s missing. If anyone can help me out I’d really appreciate it. I’ve been making good progress so far, this is the only place I’m really stuck.
Anyone have any thoughts on what might be causing this?
So I tried doing
sudo apt-get remove openhab2
sudo apt-get remove openhab2-addons
sudo apt-get install openhab2
sudo apt-get install openhab2-addons
Still getting the exact same error. Any thoughts from anyone who’s done development work before.
I hate to bother @Kai but I feel like if I can get over this hurdle and I can move on and make some progress.
Which apt repo are you using? Bindings that are compiled against the latest code base will require the “unstable” apt repo, i.e. an openHAB 2.3.0-SNAPSHOT installation (openHAB 2.2.0 won’t work with it).
How are you creating the jar file? Can u list the steps that you used to create the jar file? Did u use eclipse and menu clicks or did you use maven?
This one is most likely annotation as it is related to Eclipse Java Development Tools. If I would guess - this would be @NotNull or another static code analysis annotation.
Annotations which are not found in runtime are simply ignored. Since its marked as optional lack of it in runtime will not cause any troubles (as you do not initiate any class from this package).
This might be where my problem is. I’m using the 2.2 stable repo and compiling for 2.3 snapshot. I wasn’t aware we couldn’t use 2.3 snapshot bindings in the 2.2 repo, though it makes sense and I don’t know why that didn’t come to mind. I’ll change my repo and see if that clears it up.
I’m navigating to the directory where the binding is stored and using
mvn -e clean install
Maven should then be handling the dependancies if they are added.
By any chance do you have this warning in eclipse?
DS Annotations missing from permanent build path
If so use the quick fix feature of eclipse to resolve.
I then use
mvn clean compile package
and the JAR is then found in the target folder.
Watch all output and read and fix the warning and errors.
Unrelated question. What’s the difference between
mvn clean install and
mvn clean compile package?
I found the resolution. There were no errors as I kept the binding as simple as possible just to get it to compile and load into OpenHAB. This is my first binding and I’m taking things one step at a time to be sure I do it right.
The fix was simply switching to the snapshot build of the repo. After downloading OpenHAB 2.3.0-SNAPSHOT I added the .jar file to the addons folder and everything loaded just fine.
Thanks for the help and tips to all who contributed!