Zwave SNAPSHOT serial library woes


today I’m performing some tests on the latest zwave binding code by compiling it directly from git, but it seems I’m unable to use it from inside both an OpenHAB2-2.0.0 and a OpenHAB2-2.1.0-SNAPSHOT runtime.
Every time I try to configure the controller this is what I get in the logs:

2017-04-03 18:35:23.143 [DEBUG] [org.openhab.binding.zwave           ] - BundleEvent STARTED - org.openhab.binding.zwave
2017-04-03 18:35:23.148 [DEBUG] [org.openhab.binding.zwave           ] - ServiceEvent REGISTERED - {}={,,, service.bundleid=185, service.scope=bundle} - org.openhab.binding.zwave
2017-04-03 18:35:23.153 [DEBUG] [org.openhab.binding.zwave           ] - ServiceEvent REGISTERED - {org.eclipse.smarthome.config.core.ConfigOptionProvider, org.eclipse.smarthome.config.core.ConfigDescriptionProvider}={,,, service.bundleid=185, service.scope=bundle} - org.openhab.binding.zwave
2017-04-03 18:35:23.156 [DEBUG] [org.openhab.binding.zwave           ] - ServiceEvent REGISTERED - {org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory}={,,, service.bundleid=185, service.scope=bundle} - org.openhab.binding.zwave
2017-04-03 18:35:23.459 [DEBUG] [ing.zwave.handler.ZWaveSerialHandler] - Initializing ZWave serial controller.
2017-04-03 18:35:23.462 [DEBUG] [zwave.handler.ZWaveControllerHandler] - Initializing ZWave Controller.
2017-04-03 18:35:23.463 [INFO ] [ing.zwave.handler.ZWaveSerialHandler] - Connecting to serial port '/dev/ttyACM0'
2017-04-03 18:35:23.463 [ERROR] [ome.core.thing.internal.ThingManager] - Exception occured while initializing handler of thing 'zwave:serial_zstick:e47a3545': java.lang.NoSuchMethodError:;I)Lgnu/io/CommPort;
java.util.concurrent.ExecutionException: java.lang.NoSuchMethodError:;I)Lgnu/io/CommPort;
        at java.util.concurrent.FutureTask.get([:1.8.0_121]
        at org.eclipse.smarthome.core.common.SafeMethodCaller.callAsynchronous([99:org.eclipse.smarthome.core:]
        at org.eclipse.smarthome.core.thing.internal.ThingManager$[106:org.eclipse.smarthome.core.thing:]
        at java.util.concurrent.Executors$[:1.8.0_121]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201([:1.8.0_121]
        at java.util.concurrent.ScheduledThreadPoolExecutor$[:1.8.0_121]
        at java.util.concurrent.ThreadPoolExecutor.runWorker([:1.8.0_121]
        at java.util.concurrent.ThreadPoolExecutor$[:1.8.0_121]
Caused by: java.lang.NoSuchMethodError:;I)Lgnu/io/CommPort;
        at org.openhab.binding.zwave.handler.ZWaveSerialHandler.initialize(
        at org.eclipse.smarthome.core.thing.internal.ThingManager$9$
        at org.eclipse.smarthome.core.thing.internal.ThingManager$9$
        at org.eclipse.smarthome.core.common.SafeMethodCaller$
        ... 3 more

It seems like there’s a misalignment between the serial library used by the binding and the one available from the runtime, which is nrjavaserial (org.openhab/nrjavaserial/3.12.0.OH in both cases), installed either via the addons interface or the karaf feature openhab-transport-serial.
I previously tested the stable version of the binding (2.0.0) and it worked flawlessly with the aforementioned serial library…
Does anybody have a clue about what is going wrong here?

@chris: have you got any pointers for this?

Hi Alan,
maybe it has something to do with:


No - as far as I’m aware, nothing has changed recently. As pointed out, maybe it’s go to do with the build errors - I’m not sure though.

Thanks for the feedback. @RayBe @chris.
I’m trying to understand how this error can be happening.
Judging by the stacktrace message, it seems like there’s no CommPort open (String, int) method in the nrjavaserial library used by my OpenHAB2 runtime, which reports 3.12.0.OH as version number. Assuming that this library is built from the one forked by the OpenHab project from the original repository, I can see that the signature is slightly different:

I tried to change the zwave binding code to a RXTXPort reference instead of a CommPort one to no avail, as the code is no longer compilable after that (Type mismatch: cannot convert from CommPort to RXTXPort). BTW, the hierarchy appears to be like this: RXTXPort extends SerialPort extends CommPort.
It seems like at compile time the right nrjavaserial library is picked up and I get no complains in compiling the vanilla binding code, while at runtime a different one gets installed and then the mismatch happens.
Will try to look further into it…

Well, this is odd… I tried compiling another time (with maven) after changing the return type and this time the build process went smooth and I’m currently testing this custom version inside the openhab runtime without the previous issue.