Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java 17 Rodbus Setup Question: Unable to load any of the included native libraries #129

Open
ejrfisher opened this issue Dec 14, 2023 · 8 comments

Comments

@ejrfisher
Copy link

I have a project that I am trying to setup. Its a spring boot app using Java 17
When I attempt to create the Runtime object similarly to the example files I run into an issue regarding some native libraries.

I have hopefully formatted the structure below into somewhat orderly manner so that it can be easy to follow my setup and identify any glaring issues.

Thanks!

Exception Stack Trace

  2023-12-14 13:47:14.877 [http-nio-591-exec-1] ERROR o.a.c.c.C.[.[localhost].[/].[dispatcherServlet] - Servlet.service() for                    servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed; nested exception is java.lang.ExceptionInInitializerError] with root cause
  java.lang.Exception: Unable to load any of the included native libraries
	  at io.stepfunc.rodbus.NativeFunctions.<clinit>(NativeFunctions.java:53)
	  at io.stepfunc.rodbus.NativeFunctions$Wrapped.runtime_create(NativeFunctions.java:193)
	  at io.stepfunc.rodbus.Runtime.<init>(Runtime.java:37)

Method Throwing Error (specifically the second line here is the culprit)

        RuntimeConfig runtimeConfig = new RuntimeConfig().withNumCoreThreads(ushort(4));
        Runtime runtime = new Runtime(runtimeConfig);

Java Version

  java 17.0.6 2023-01-17 LTS
  Java(TM) SE Runtime Environment (build 17.0.6+9-LTS-190)
  Java HotSpot(TM) 64-Bit Server VM (build 17.0.6+9-LTS-190, mixed mode, sharing)

pom.xml snippet

        <dependency>
            <groupId>io.stepfunc</groupId>
            <artifactId>rodbus</artifactId>
            <version>1.3.1</version>
        </dependency>

        <dependency>
            <groupId>org.jooq</groupId>
            <artifactId>joou</artifactId>
            <version>0.9.4</version>
        </dependency>

class imports

  import static org.joou.Unsigned.ubyte;
  import static org.joou.Unsigned.ushort;
  import io.stepfunc.rodbus.*;
  import io.stepfunc.rodbus.Runtime;

Let me know if I am overlooking something in my setup here or if there is any additional information that you need to help me with this issue!
Thanks

@jadamcrain
Copy link
Member

jadamcrain commented Dec 14, 2023 via email

@ejrfisher
Copy link
Author

ejrfisher commented Dec 14, 2023

MacOs - 14.2
ARM - Apple M1 Max

If it at all matters: I have also tried running the application in a docker container, and although the error output is different the culprit seems to be the same Runtime object

@jadamcrain
Copy link
Member

jadamcrain commented Dec 15, 2023 via email

@ejrfisher
Copy link
Author

From my understanding the docker daemon manages the "architecture" of the built image. I can try to set a target platform/architecture otherwise its just based off the base image which for this specific example was eclipse-temurin:17-alpine

which was AMD64 not ARM64/aarch64...

Ill try and find an image to build off of that is actually aarch64 and go from there

@ejrfisher
Copy link
Author

I now have a linux based image running with aarch64 architecture for the same app in docker container but I am still running into an error when creating the Runtime Object .

Error Message

2023-12-15 11:13:43 thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: JavaException', /target/aarch64-unknown-linux-gnu/release/build/rodbus-ffi-java-1095f2a2549debe7/out/jni.rs:3439:187
2023-12-15 11:13:43 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
2023-12-15 11:13:43 fatal runtime error: failed to initiate panic, error 4164302448

os info

 cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.3 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.3 LTS (Jammy Jellyfish)"

Architecture info

# lscpu
Architecture:           aarch64
  CPU op-mode(s):       64-bit
  Byte Order:           Little Endian

Let me know if theres any more info I can provide

@ejrfisher
Copy link
Author

ejrfisher commented Dec 26, 2023

Moved my project up to java 21 to see if that changed anything locally or in docker. No change
Read through the mentioned issue, but not sure if it relates to the errors I am seeing or if there is a new release for the rodbus library?

@jadamcrain
Copy link
Member

No new release for the Rodbus library yet.

I plan to do a maintenance release soon that will incorporate some more debug info into the Java library loading process. Maybe that will shed some light on what's going on in your app.

@ejrfisher
Copy link
Author

ejrfisher commented Dec 26, 2023

Sounds great! Thanks for the update

edit: seems like the Runtime Object is no longer the culprit for this error but instead its moved down to either DeviceMap or ClientChannel.createTcp I'll update the issue if I can find a better description of the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants