luben / zstd-jni

JNI binding for Zstd
Other
808 stars 165 forks source link

Unsupported OS/arch, cannot find /linux/aarch_64/libzstd-jni-1.5.6-3.so or load zstd-jni-1.5.6-3 from system libraries. #318

Closed suddendust closed 1 week ago

suddendust commented 2 weeks ago

I am trying to port my app to linux/aarch64 and getting this exception:

Caused by: java.lang.ExceptionInInitializerError: Exception java.lang.UnsatisfiedLinkError: no zstd-jni-1.5.6-3 in java.library.path: /usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib
Unsupported OS/arch, cannot find /linux/aarch_64/libzstd-jni-1.5.6-3.so or load zstd-jni-1.5.6-3 from system libraries. Please try building from source the jar or providing libzstd-jni-1.5.6-3 in your system. [in thread "Thread-25"]
        at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2458)
        at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:916)
        at java.base/java.lang.System.loadLibrary(System.java:2063)
        at com.github.luben.zstd.util.Native$1.run(Native.java:70)
        at com.github.luben.zstd.util.Native$1.run(Native.java:68)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:319)
        at com.github.luben.zstd.util.Native.loadLibrary(Native.java:68)
        at com.github.luben.zstd.util.Native.load(Native.java:118)
        at com.github.luben.zstd.util.Native.load(Native.java:86)
        at com.github.luben.zstd.Zstd.<clinit>(Zstd.java:12)
        at org.apache.pinot.segment.local.io.compression.ZstandardCompressor.maxCompressedSize(ZstandardCompressor.java:53)
        at org.apache.pinot.segment.local.io.compression.TestCompression.lambda$testConcurrent$0(TestCompression.java:108)
        at java.base/java.lang.Thread.run(Thread.java:1583)

Although I see that we do have a binary for aarch64 in the jar at path linux/aarch64/libzstd-jni-1.5.6-3.so, the code, however, looks for it in aarch_64 instead of aarch64.

Zstd loads the the following native library: /linux/aarch_64/libzstd-jni-1.5.6-3.so

In code, this name is derived using:

  private static String resourceName() {
        return "/" + osName() + "/" + osArch() + "/" + libname + "." + libExtension();
    }

And osArch() basically reads the env var os.arch:

  private static String osArch() {
        return System.getProperty("os.arch");
    }

I checked this, it returns aarch64 in my container so why is it looking for aarch_64 then?

luben commented 2 weeks ago

No idea. Any chance you explicitly set it as java CLI argument?

suddendust commented 1 week ago

@luben That was the mistake 🤦 I was overriding it to aarch_64 in the maven command. Closing this issue.