IDE & Build Setup for updating an old v1.x binding (NeoHub)

Dependencies are not resolved for manually installed bindings. The zwave binding has a similar issue with xstream in recent snapshots. You could try downloading the jar (I think this is what you need) and dropping it into addons. That won’t help debug it directly in the IDE, but you should be able to run it in OH and debug remotely.

Hi Scott, thanks for the insight.

It seems that the openHAB standard runtime actually already includes the following “jackson” JAR modules…

jackson-annotations-2.4.5.jar
jackson-core-2.4.5.jar

But when I put my plugin JAR file in the addons folder, the openHAB reports the following error …

Unresolved requirement: .. org.codehaus.jackson.annotate; version="[1.9.0,2.0.0)"

So the problem seems to be that openHAB cannot find a common denominator between the available and the required jackson versions.

And my problem is that it is a transient dependency of my plugin which is caused in other legacy openHAB core code which is beyond my control.

I tried dropping the jackson v2.0.0 JAR files into the openHAB “addons” folder and/or into the “lib/ext” folder, but neither of these has any impact.

Zwave shows the same behavior. Xstream is there, but the binding does not have access to it. Dropping the jar in addons adds it to the classpath and the binding can access it. Versions could complicate things for you too, so drop the right version for your binding.

Which ones? I was guessing with the link I provided and they could be something else. I’m unfamiliar with org.codehaus.jackson.annotate. As David mentioned, these are now fasterxml, so you may need the other ones. The link was to the fasterxml ones.

Good catch! I will look for the codehaus versions. Thanks.

I’m sorry but I am really struggling with this. So I hope you can continue to help me :slight_smile:

I changed the code of the bundle plugin to import the “fasterxml” JSON packages (instead of the old “codehaus” ones) , and I added the FasterXML dependencies to its pom file, as follows.

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.4.5</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.4.5</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.4.5</version>
</dependency>

Now I can build the binding plugin’s JAR file (it builds successfully using either Eclipe or MVN). But when I drop the JAR file in the addons folder I still get the following error log message from openHAB

Unresolved requirement: Import-Package: com.fasterxml.jackson.annotation; version="[2.4.0,3.0.0)"

I really don’t see why I am getting this message since the openHAB application does have the exact required JAR files in its runtime as follows…

\\OPENHABIANPI\openHAB-share\openhab2-sys\runtime\system\com\fasterxml\jackson\core\jackson-annotations\2.4.5
\\OPENHABIANPI\openHAB-share\openhab2-sys\runtime\system\com\fasterxml\jackson\core\jackson-core\2.4.5
\\OPENHABIANPI\openHAB-share\openhab2-sys\runtime\system\com\fasterxml\jackson\core\jackson-databind\2.4.5
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.4.5</version>
<scope>provided</scope> IMPORTANT
</dependency>

You need a provided scope. At the moment you include the library into your jar and the framework ends up confused.

For a running openHAB instance: It must be part of the features.xml file (each new bundle has one of these now, check the addons2 repo). That file is not part of the build .jar file though. What you want is to build a .kar file instead (karaf bundle file) and drop that into the addons dir. I forgot the maven command to do so though :confused:

If you do local development via the demo app: It must be part of the bndrun file. Usually it is automatically added when you click the “resolve” button or execute maven with “-DwithResolver”.

Many thanks for the feedback David!

Hmm. I tried adding the “scope-provided” tags – but I think that made it worse (??) since now I get two errors rather than one – namely a “FrameworkEvent” error plus also an “Error while starting bundle” – see below…

2019-05-16 18:56:02.932 [ERROR] [org.openhab.binding.neohub          ] - FrameworkEvent ERROR - org.openhab.binding.neohub
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.neohub [251]
  Unresolved requirement: Import-Package: com.fasterxml.jackson.annotation; version="[2.4.0,3.0.0)"
...
2019-05-16 18:56:12.146 [WARN ] [org.apache.felix.fileinstall        ] - Error while starting bundle: file:/usr/share/openhab2/addons/org.openhab.binding.neohub-2.5.0-SNAPSHOT.jar
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.neohub [251]
  Unresolved requirement: Import-Package: com.fasterxml.jackson.annotation; version="[2.4.0,3.0.0)"

The Maven build process does already create a feature.xml file in the target directory…

I tried this ( Using the karaf-maven-plugin ) but it caused even more build errors… :frowning:

Hm. The kar file would be the easy solution. I have started the discussion on GitHub some time ago to create kar files as well. I haven’t done that for some time, might indeed be broken right now.

A second way is to just inject the library itself into karaf. Either by dropping the respective jar file into the add-ons dir or by using bundle:install on the console with the URL to the Jackson url on maven central.

That wasn’t working for zwave, but dropping the jar works.

May I ask you guys what is your strategy for future handling of cases like this?

The NeoHub is an old legacy v1.x binding that works. The hardware manufacturer is still actively selling their products, and they are still actively supporting the already defined JSON interface. They have recently added some products to their range which have properties that are already accessible via the already existing JSON interface, but the respective existing OpenHAB legacy binding does not pick those properties up yet. All I want to do is add about 20 lines of code to the existing legacy binding, in order to pick up those properties.

I don’t have the skill set or motivation to rewrite the v1x binding in v2x format. All I want to do is re-build the existing legacy binding with my 20 extra lines of code. It seems that this is impossible.

So I would like to ask if you have any plan or concept for such binding maintenance work?

The current developers that I know of do not use OH1 bindings, so they are basically in a non maintained state.

The buildsystem changed and dependencies changed already and soon openhab core package names will change. So eventually all OH1 bindings will break at some point. That’s why it is important to save valuable code over to the OH2-addons repo.

I haven’t tried in over a year or so. But the the openhab1-addon repository contains tags to the old 1.x runtime. You use to be able to clone the 1.8.3 tag and run mvn clean install on the root folder and everything still built. At that point you could manually copy over your code. If not I think I have a 1.x build environment still working on my computer, if you just want the jar file.

Scott

word

Hi @Andrew_Rowe I am not sure I understand what you mean; is you message intended for me ?

Hi Andrew:
Basically, I was saying I agree with what you said. This is a thorny issue for OpenHAB. An OH v1 binding that works, people are using it, (obviously) and there needs to be some way where it can be maintained and continue to be used.
Sorry I wasn’t more clear

Thanks for the clarification @Andrew_Rowe

Sorry @scooter_seh but that did not work :frowning:

Any news @David_Graeff ??

Sorry but it doesn’t work for me @5iver :frowning:

So guys, I am stuck. What do I do next?

No news. The development IDE setup must be worked out at the moment.

Two updates…

I ended up just sticking the Jackson JAR files in my lib folder. This bloats my JAR by about 1MB due to these duplicated JARs, but this seems to be the only way to get my plugin to build and load.

In the meantime, I also wrote a first BETA of a new v2.x “NeoHub” binding (link below); it is not fully tested yet, so I am not yet making a pull request; but if you want to look at it you are welcome.

PS I migrated the JSON parser code from Jackson to GSON, and now I have been able to resolve the dependencies. :slight_smile:

1 Like

I am pleased to announce that my NeoHub v2 binding for OH2 is now available for testing…

1 Like