GraalVM and JNA dependency

255 views Asked by At

I can not start my application with JNA dependencies. Compilation of the app was ok, but on starting/runtime the JNA library can not be found. From the IDE - no problem but not from the native-compiled version. Did I forget something for loading resources? How can I configure graalvm to make them find the dependency? I am using the gradle-plugin: org.graalvm.buildtools.native

Exception in thread "main" java.lang.UnsatisfiedLinkError: Native library (com/sun/jna/win32-x86-64/jnidispatch.dll) not found in resource path ()
    at com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:1059)
    at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:1015)
    at com.sun.jna.Native.<clinit>(Native.java:221)
    at com.sun.jna.NativeLong.<clinit>(NativeLong.java:35)
    at [email protected]/java.lang.Class.ensureInitialized(DynamicHub.java:579)
1

There are 1 answers

0
Tony On

Got it, it worked with the following combination:

  • I used the Graal-Agent to generate metadata-files (Tracing Agent)

  • Added all of them to the gradle definition like this

     buildArgs.add("-H:JNIConfigurationFiles=${projectDir}/src/main/resources/conf/jni-config.json")
     buildArgs.add("-H:DynamicProxyConfigurationFiles=${projectDir}/src/main/resources/conf/proxy-config.json")
     buildArgs.add("-H:ReflectionConfigurationFiles=${projectDir}/src/main/resources/conf/reflect-config.json")
     buildArgs.add("-H:ResourceConfigurationFiles=${projectDir}/src/main/resources/conf/resource-config.json")
    
  • added buildArgs.add('-H:+JNI')

  • removed buildArgs.add('--initialize-at-build-time') (Don't know why this is required)