snappy-java icon indicating copy to clipboard operation
snappy-java copied to clipboard

Exception in thread "main" org.xerial.snappy.SnappyError: [FAILED_TO_LOAD_NATIVE_LIBRARY] no native library is found for os.name=AIX and os.arch=ppc64

Open ThakkarChandresh opened this issue 1 year ago • 3 comments

I've observed that while running the snappy in the IBM AIX 7.2 it gives the error,

Exception in thread "main" org.xerial.snappy.SnappyError: [FAILED_TO_LOAD_NATIVE_LIBRARY] no native library is found for os.name=AIX and os.arch=ppc64
        at org.xerial.snappy.SnappyLoader.findNativeLibrary(SnappyLoader.java:345)
        at org.xerial.snappy.SnappyLoader.loadNativeLibrary(SnappyLoader.java:179)
        at org.xerial.snappy.SnappyLoader.loadSnappyApi(SnappyLoader.java:157)
        at org.xerial.snappy.Snappy.init(Snappy.java:70)
        at org.xerial.snappy.Snappy.<clinit>(Snappy.java:47)

I've tried to find the RCA, to do so I've first manually put the aix related native libraries and passed them as variables

jdk/bin/./java -Dorg.xerial.snappy.lib.path=/tmp -Dorg.xerial.snappy.lib.name=libsnappyjava.a -cp Demo.jar:lib/* com.demo.Bootstrap

And it worked! So I tried to find that by default (if we're not passing any variable) why it's not able to find that file?

So I've added a print statement and tried to debug, there I've noticed that it tries to find the file at the correct destination, But what I've noticed is that the file extension is different.

has resource /org/xerial/snappy/native/AIX/ppc64/libsnappyjava.so

And the native file that is present in the jar have a different file extension,

total 264
-rw-r--r-- 1 root root 266695 Aug  7 05:49 libsnappyjava.a
root@demo:/demo/snappy/org/xerial/snappy/native/AIX/ppc64#

And in the code, the file's extension is entirely dependent on the System class, And the System class it self returns the .so extension instead of .a and this extension issue is also a very popular issue.

So what's the correct extension?? Is there no alternate way than passing the variable??

ThakkarChandresh avatar Oct 07 '24 14:10 ThakkarChandresh

We haven't updated IBM AIX native libraries (.a) for almost 7 years since the last contribution from @odaira-san: https://github.com/xerial/snappy-java/tree/master/src/main/resources/org/xerial/snappy/native/AIX

I guess there was some system-side change around IBM AIX or JDK library to return .so instead of .a extension at https://github.com/xerial/snappy-java/blob/85966bbb1bd3d4e7a41ac51958fbab59456348c1/src/main/java/org/xerial/snappy/SnappyLoader.java#L319

As the current native library is quite old, if possible, I'd like to receive a pull request to update it, compiled with the make native command. If .so is the current default extension, that command will generate a .so file.

xerial avatar Oct 08 '24 21:10 xerial

I will try to generate the native library, if it works in IBM AIX then I will raise a PR.

ThakkarChandresh avatar Oct 10 '24 07:10 ThakkarChandresh

I'm a little bit unaware of the native library building, it would be better if you had some reference for it like where is the code of the native library how I can clone it, and where I can execute a make command to build the native library and all.

ThakkarChandresh avatar Oct 10 '24 07:10 ThakkarChandresh