oracle / graal

GraalVM compiles Java applications into native executables that start instantly, scale fast, and use fewer compute resources 🚀
https://www.graalvm.org
Other
20.27k stars 1.63k forks source link

Caused by: java.lang.RuntimeException: java.lang.NoClassDefFoundError: ai.onnxruntime.OrtSession$SessionOptions #8752

Open yongxin3344520 opened 5 months ago

yongxin3344520 commented 5 months ago

============= win10 , java21

I used GraalVM 21 to package my project, which introduced the onnxruntime jar.

<plugin>
      <groupId>org. galalvm. buildtools</groupId>
      <artifactId>native aven plugin</artifactId>
      <configuration>
      <buildArgs>
      <arg>- H:+AllowDeprecatedBuilderClassesOnImageClasspath</arg>
      </buildArgs>
</configuration>
</plugin>

After successful packaging, run exe with an exception: Caused by: Java. lang. RuntimeException: Java. lang. NoClassDefFoundError: ai. onnxruntime OrtSession $SessionOptions.

======================

If commented out:

- H:+AllowDeprecatedBuilderClassesOnImageClasspath

When using the command: mvn - Native Native Native: compile to package as exe, an error will be reported: Error: Class path entry file:///F:/B/yolo_tiny/target/classes/ Contains class ai.onnxruntime MapInfo This class is part of the image builder itself (in file:///D:/java/graalvm -Jdk-21.0.2+13.1/lib/svm/builder/svm enterprise. jar) and must not be passed via cp. This can be caused by a fat jar that Illegally includes svm. jar (or grain sdk. jar) due to its build time dependency on it. As a workaround, - H:+AllowDeprecatedBuilderClassesOnImageClasspath allows turning this error into a warning Note that this option is deprecated and will be removed in a future version 。

How should I handle it, may I ask? thanks!

fernando-valdez commented 5 months ago

Hi. To understand the issue, please provide the following information:

Taymindis commented 5 months ago

Just setup your reflection.json config will fix the issue