objectbox / objectbox-java

Android Database - first and fast, lightweight on-device vector database
https://objectbox.io
Apache License 2.0
4.33k stars 297 forks source link

java.lang.UnsatisfiedLinkError: no objectbox-jni in java.library.path /usr/java/packages/lib:/usr/lib/aarch64-linux-gnu/jni:/lib/aarch64-linux-gnu:/usr/lib/aarch64-linux-gnu:/usr/lib/jni:/lib:/usr/lib #1130

Closed maihasegauwa closed 1 year ago

maihasegauwa commented 1 year ago

A SpringBoot application written in Kotlin, employing ObjectBox as a temp/cache data storage. Works in both Windows and Linux on AMD64 platformed hosts. However, after migrating to UTM's AARCH64 on MacOS, got the following issue when starting the application: Caused by: java.lang.LinkageError: [ObjectBox] Loading native library failed, please report this to us: vendor=Private Build,os=linux,os.arch=aarch64,model=64,linux=true,machine=aarch64 at io.objectbox.internal.NativeLibraryLoader.(NativeLibraryLoader.java:130) at io.objectbox.BoxStore.(BoxStore.java:261) at io.objectbox.BoxStoreBuilder.build(BoxStoreBuilder.java:549) at com.ouroboros.owall.monitor.persistence.objectbox.ObjectBoxManagerService.init(ObjectBoxManagerService.kt:24) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:389) at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:333) at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:157) ... 68 common frames omitted Caused by: java.lang.UnsatisfiedLinkError: no objectbox-jni in java.library.path: /usr/java/packages/lib:/usr/lib/aarch64-linux-gnu/jni:/lib/aarch64-linux-gnu:/usr/lib/aarch64-linux-gnu:/usr/lib/jni:/lib:/usr/lib at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2429) at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:818) at java.base/java.lang.System.loadLibrary(System.java:1989) at io.objectbox.internal.NativeLibraryLoader.(NativeLibraryLoader.java:104) ... 78 common frames omitted

To Reproduce Steps to reproduce the behavior:

  1. Create a SpringBoot app on Kotlin, add ObjectBox dependencies (java and kotlin)
  2. Put the application onto the MacOS UTM Virtualized guest
  3. Launch and see the error

Expected behavior As per this Reddit post https://www.reddit.com/r/java/comments/12x5m7l/will_objectbox_ever_support_aarm64_architecture/, greenbot_de user indicated, that latest ObjectBox java library supports the AARM64 arch.

Code Build script: val objectBoxVersion = "3.5.1" implementation("io.objectbox:objectbox-linux:$objectBoxVersion") implementation("io.objectbox:objectbox-java:$objectBoxVersion") implementation("io.objectbox:objectbox-kotlin:$objectBoxVersion") runtimeOnly("io.objectbox:objectbox-windows:$objectBoxVersion") // Not used, because it is a MacOS build and run Init script: MyObjectBox .builder() .name(dbName) .maxSizeInKByte(dbMaxSizeGb * 1000000L) .build()

Logs, stack traces If applicable, add relevant logs, or a stack trace.

Additional context Add any other context about the problem here.

maihasegauwa commented 1 year ago

I have found what the problem was: i used a simple linux dependency, whereas, I should have used linux-arm64 dependency. Now that I have added it - it works fine. Thank you.

greenrobot-team commented 1 year ago

For others coming here, see https://docs.objectbox.io/advanced/advanced-setup#manually-add-libraries on how to manually add additional dependencies for other architectures.