RXTXComm: portIdentifier.open java.lang.NoSuchMethodError

I cannot instantiate a serial connection. The same code works with a Main Class as a plan java application.

I made the following changes in the openHAB2 runtime:
VM Arguments:
-Djava.library.path=/usr/lib/jni/ -cp /usr/share/java/RXTXcomm.jar

This works on my 64Bit Linux and the raspberry pi in the same way.

When I call
CommPort commPort = portIdentifier.open(“waschapp”, 2000);

I get the following exception:

2017-08-25 00:04:59.029 [ERROR] [.c.thing.internal.ThingManager:757 ] - Exception occurred while initializing handler of thing ‘waschabrechnung:Waschstrasse:7f11a157’: java.lang.NoSuchMethodError: gnu.io.CommPortIdentifier.open(Ljava/lang/String;I)Lgnu/io/CommPort;java.util.concurrent.ExecutionException: java.lang.NoSuchMethodError: gnu.io.CommPortIdentifier.open(Ljava/lang/String;I)Lgnu/io/CommPort;
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:206)
at org.eclipse.smarthome.core.common.SafeMethodCaller.callAsynchronous(SafeMethodCaller.java:194)
at org.eclipse.smarthome.core.common.SafeMethodCaller.call(SafeMethodCaller.java:83)
at org.eclipse.smarthome.core.common.SafeMethodCaller.call(SafeMethodCaller.java:67)
at org.eclipse.smarthome.core.thing.internal.ThingManager.doInitializeHandler(ThingManager.java:742)
at org.eclipse.smarthome.core.thing.internal.ThingManager.initializeHandler(ThingManager.java:677)
at org.eclipse.smarthome.core.thing.internal.ThingManager.registerAndInitializeHandler(ThingManager.java:1055)
at org.eclipse.smarthome.core.thing.internal.ThingManager.thingAdded(ThingManager.java:472)
at org.eclipse.smarthome.core.thing.internal.ThingRegistryImpl.notifyTrackerAboutAllThingsAdded(ThingRegistryImpl.java:224)
at org.eclipse.smarthome.core.thing.internal.ThingRegistryImpl.addThingTracker(ThingRegistryImpl.java:62)
Caused by: java.lang.NoSuchMethodError: gnu.io.CommPortIdentifier.open(Ljava/lang/String;I)Lgnu/io/CommPort;
at de.abl.wacomp.serial.SerialImpl.connect(SerialImpl.java:75)
at org.openhab.binding.waschabrechnung.handler.WaschAbrechnungHandler.initialize(WaschAbrechnungHandler.java:158)
at org.eclipse.smarthome.core.thing.internal.ThingManager$8.call(ThingManager.java:745)
at org.eclipse.smarthome.core.thing.internal.ThingManager$8.call(ThingManager.java:1)
at org.eclipse.smarthome.core.common.SafeMethodCaller$CallableWrapper.call(SafeMethodCaller.java:181)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
… 1 common frames omitted

Any ideas?

Thanks in advance
Jens Riebold

Hi,

I just resolved the problem by switching to nrjavaserial. I thought that I could use my jar file unchanged but that caused the problems.

My code runs fine, even on a raspberry pi.