graal icon indicating copy to clipboard operation
graal copied to clipboard

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

Open yongxin3344520 opened this issue 2 months ago • 2 comments

============= 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!

yongxin3344520 avatar Apr 11 '24 19:04 yongxin3344520

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

  • The exact version of GraalVM, that will be the full output of java -version
  • A minimal reproducer that we can use to get the same error locally.
  • The steps you followed to get this error.

fernando-valdez avatar Apr 12 '24 02:04 fernando-valdez

Just setup your reflection.json config will fix the issue

Taymindis avatar Apr 12 '24 10:04 Taymindis