jSerialComm problem in raspberry4B

Hi there,
i have tried openems.jar in windows,ubuntu,all works fine.but when i move to raspberry 4B , there was the error:

2月 20 13:12:25 raspberrypi java[7929]: java.lang.NoClassDefFoundError: Could not initialize class com.fazecast.jSerialComm.SerialPort
2月 20 13:12:25 raspberrypi java[7929]:         at com.ghgande.j2mod.modbus.net.SerialConnection.open(SerialConnection.java:90)
2月 20 13:12:25 raspberrypi java[7929]:         at io.openems.edge.bridge.modbus.BridgeModbusSerialImpl.getModbusConnection(BridgeModbusSerialImpl.java:137)
2月 20 13:12:25 raspberrypi java[7929]:         at io.openems.edge.bridge.modbus.BridgeModbusSerialImpl.getNewModbusTransaction(BridgeModbusSerialImpl.java:111)
2月 20 13:12:25 raspberrypi java[7929]:         at io.openems.edge.bridge.modbus.api.task.AbstractTask.sendRequest(AbstractTask.java:352)
2月 20 13:12:25 raspberrypi java[7929]:         at io.openems.edge.bridge.modbus.api.task.AbstractTask.lambda$0(AbstractTask.java:117)
2月 20 13:12:25 raspberrypi java[7929]:         at io.openems.edge.bridge.modbus.api.task.AbstractTask.logRequest(AbstractTask.java:143)
2月 20 13:12:25 raspberrypi java[7929]:         at io.openems.edge.bridge.modbus.api.task.AbstractTask.executeRequest(AbstractTask.java:116)
2月 20 13:12:25 raspberrypi java[7929]:         at io.openems.edge.bridge.modbus.api.task.AbstractReadTask.execute(AbstractReadTask.java:44)
2月 20 13:12:25 raspberrypi java[7929]:         at io.openems.edge.bridge.modbus.api.AbstractModbusBridge.lambda$0(AbstractModbusBridge.java:43)
2月 20 13:12:25 raspberrypi java[7929]:         at io.openems.edge.bridge.modbus.api.worker.ModbusWorker.forever(ModbusWorker.java:74)
2月 20 13:12:25 raspberrypi java[7929]:         at io.openems.common.worker.AbstractWorker$1.run(AbstractWorker.java:129)
2月 20 13:12:25 raspberrypi java[7929]: Caused by: java.lang.ExceptionInInitializerError: Exception java.lang.UnsatisfiedLinkError: /tmp/1708405814231-libjSerialComm.so: /tmp/1708405814231-libjSerialComm.so: 无法打开共享对象文件: 没有那个文件或目录 [in>
2月 20 13:12:25 raspberrypi java[7929]:         at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
2月 20 13:12:25 raspberrypi java[7929]:         at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:388)
2月 20 13:12:25 raspberrypi java[7929]:         at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:232)
2月 20 13:12:25 raspberrypi java[7929]:         at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:174)
2月 20 13:12:25 raspberrypi java[7929]:         at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2394)
2月 20 13:12:25 raspberrypi java[7929]:         at java.base/java.lang.Runtime.load0(Runtime.java:755)
2月 20 13:12:25 raspberrypi java[7929]:         at java.base/java.lang.System.load(System.java:1953)
2月 20 13:12:25 raspberrypi java[7929]:         at com.fazecast.jSerialComm.SerialPort.<clinit>(SerialPort.java:248)
2月 20 13:12:25 raspberrypi java[7929]:         ... 11 more

i search for this problem and i found that it possibly means i dont have jSerialComm.so installed in my system, or jvm ? But the thing is it works fine in normal ubuntu system , but error in raspberry ubuntu system.

Anyone can help explain what this error is or how do i install this package in my raspberry system.

Thank so much

Hello, Zaohon.

I am successfully running OpenEMS Backend and OpenEMS Edge on a Raspberry Pi 4 and 5, respectively.

Can you give us more information about what you are trying to do and at what point you are getting this error? Are you in the middle of installing Edge or Backend? Are you getting this error when running a particular device or controller in OpenEMS Edge? What OS are you trying to run on the Pi? Anything else you could share so that we can try and help you?

Hi,acabrera

Thank u very much for ur reply,letting me know it is feasible to run openems on Raspberry Pi 4.

I am now actually trying to run OpenEMS Edge on a Raspberry Pi 4B , raspberry OS.I get this error when i was trying to use modbus/RTU to connect one electrical meter.This error happens when OpenEMS try to fetch datas by modbus via a serial port,let’s say /dev/ttyusb0 here.

To ensure that it is not a problem of this serial port , i have tested the connection and fetch datas by minicom,a tool for testing serial port,and it works,which means at least the serial port itself works fine.

Then i move to OpenEMS Edge , config modbus RTU with /dev/ttyusb0 in it , and i have written the meter before , let’s call it dds5188 . i create a new project for it . it works perfectly in my windows and another ubuntu computer,ensuring that the code is fine.

And then the bug arised like i mentioned in front . Actually i have searched a lot for the solution . I found that it is probably an error of “libjSerialComm.so”,this is a library which handles serial connection work in openEMS.People who discuss in SerialComm github issues say that they meet the same UnsatisfiedLinkError when using this library in raspberry , probly because of the different of hardware structure , checking this : https://github.com/Fazecast/jSerialComm/issues/503 and thishttps://github.com/Fazecast/jSerialComm/issues/277.

And by the way , are your raspberry’s OS the normal raspberry ubuntu ?And if it is ok,can u send me ur ems.jar for only testing.

Tell me if i have something explained unclear,
Thanks very much in advanced

Here are some notes:

  • I am running Raspberry Pi OS (Bookworm) on both Pi’s
  • Check your version of GLIBC by running

ldd --version

It may need to be at least 2.28 to run jSerialComm. Mine is 2.36

  • Be sure that the Pi user is a member of the dialout group for accessing the serial port. If the user is named “pi”, you would use something like

sudo usermod -a -G dialout pi

Hi acabrera,

Thank u very much for giving me advice,I checked my GLIBC version , it is 2.3.1

ldd (Debian GLIBC 2.31-13+rpt2+rpi1+deb11u7) 2.31

And indeed,my user is named “pi”,so i haved typed

sudo usermod -a -G dialout pi

But then there is still the error like:

2月 23 15:28:44 raspberrypi java[1437]: 2024-02-23T15:28:44,404 [modbus0 ] ERROR [s.common.worker.AbstractWorker] Worker error. NoClassDefFoundError: Could not initialize class com.fazecast.jSerialComm.SerialPort - Caused by: Exception java.lang.UnsatisfiedLinkError: /var/customtmp/1708673100567-libjSerialComm.so: /var/customtmp/1708673100567-libjSerialComm.so: 无法打开共享对象文件: 没有那个文件或目录 [in thread "modbus0"]
2月 23 15:28:44 raspberrypi java[1437]: java.lang.NoClassDefFoundError: Could not initialize class com.fazecast.jSerialComm.SerialPort
2月 23 15:28:44 raspberrypi java[1437]:         at com.ghgande.j2mod.modbus.net.SerialConnection.open(SerialConnection.java:90)
2月 23 15:28:44 raspberrypi java[1437]:         at io.openems.edge.bridge.modbus.BridgeModbusSerialImpl.getModbusConnection(BridgeModbusSerialImpl.java:137)
2月 23 15:28:44 raspberrypi java[1437]:         at io.openems.edge.bridge.modbus.BridgeModbusSerialImpl.getNewModbusTransaction(BridgeModbusSerialImpl.java:111)
2月 23 15:28:44 raspberrypi java[1437]:         at io.openems.edge.bridge.modbus.api.task.AbstractTask.sendRequest(AbstractTask.java:352)
2月 23 15:28:44 raspberrypi java[1437]:         at io.openems.edge.bridge.modbus.api.task.AbstractTask.lambda$0(AbstractTask.java:117)
2月 23 15:28:44 raspberrypi java[1437]:         at io.openems.edge.bridge.modbus.api.task.AbstractTask.logRequest(AbstractTask.java:143)
2月 23 15:28:44 raspberrypi java[1437]:         at io.openems.edge.bridge.modbus.api.task.AbstractTask.executeRequest(AbstractTask.java:116)
2月 23 15:28:44 raspberrypi java[1437]:         at io.openems.edge.bridge.modbus.api.task.AbstractReadTask.execute(AbstractReadTask.java:44)
2月 23 15:28:44 raspberrypi java[1437]:         at io.openems.edge.bridge.modbus.api.AbstractModbusBridge.lambda$0(AbstractModbusBridge.java:43)
2月 23 15:28:44 raspberrypi java[1437]:         at io.openems.edge.bridge.modbus.api.worker.ModbusWorker.forever(ModbusWorker.java:74)
2月 23 15:28:44 raspberrypi java[1437]:         at io.openems.common.worker.AbstractWorker$1.run(AbstractWorker.java:129)
2月 23 15:28:44 raspberrypi java[1437]: Caused by: java.lang.ExceptionInInitializerError: Exception java.lang.UnsatisfiedLinkError: /var/customtmp/1708673100567-libjSerialComm.so: /var/customtmp/1708673100567-libjSerialComm.so: 无法打开共享对象文件: 没 有那个文件或目录 [in thread "modbus0"]
2月 23 15:28:44 raspberrypi java[1437]:         at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
2月 23 15:28:44 raspberrypi java[1437]:         at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:388)
2月 23 15:28:44 raspberrypi java[1437]:         at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:232)
2月 23 15:28:44 raspberrypi java[1437]:         at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:174)
2月 23 15:28:44 raspberrypi java[1437]:         at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2394)
2月 23 15:28:44 raspberrypi java[1437]:         at java.base/java.lang.Runtime.load0(Runtime.java:755)
2月 23 15:28:44 raspberrypi java[1437]:         at java.base/java.lang.System.load(System.java:1953)
2月 23 15:28:44 raspberrypi java[1437]:         at com.fazecast.jSerialComm.SerialPort.<clinit>(SerialPort.java:248)
2月 23 15:28:44 raspberrypi java[1437]:         ... 11 more
2月 23 15:28:44 raspberrypi java[1437]: 2024-02-23T15:28:44,418 [_cycle  ] INFO  [ebuglog.ControllerDebugLogImpl] [Log] _sum[State:Ok Ess SoC:50 %|L:-244 W Grid:0 W Production:244 W Consumption:0 W] dds5188[L:UNDEFINED UNDEFINED UNDEFINED] ess[SoC:50 %|L:-244 W|Allowed:-10000;10000 W] grid[0 W] pv_meter[244 W]

And my openems.service is like this below,if it is useful:


[Unit]
Description=OpenEMS Edge
After=network.target

[Service]
User=root
Group=root
Type=notify
WorkingDirectory=/usr/lib/openems
ExecStart=java -Djava.io.tmpdir=/var/customtmp/ -Dfelix.cm.dir=/etc/openems.d/ >
SuccessExitStatus=143
Restart=always
RestartSec=10
WatchdogSec=60

[Install]
WantedBy=multi-user.target

Anything else idea for this error ? i probably get that it should be an error of permission stuff , but i have no idea how to fix it .

Thanks in advance again

HI,there:

I fixed it , thanks for acabrera very much.

Now i update the os of my raspberry to newest version which is 2023/12/29,i forget the day,and i change the user name to not “pi” , then the bug fixed.

I dont know exctly how i fix this , probably because of the user name , or the version of OS,but anyway i fix this.

By the way, the version of GLIBC now is 2.36,in newest raspberry OS.

Thanks for this community

1 Like