sbt-native-packager
sbt-native-packager copied to clipboard
Native image executable: could not find or load main class
Expected behaviour
graalvm-native-image:packageBin produce an executable, that can be execute from anywhere if exported.
Actual behaviour
graalvm-native-image:packageBin produce an executable, that work properly if started in target/graalvm-native-image.
But doesn't If moved anywhere else, or if target/scala-2.13/classes are deleted:
Error: Could not find or load main class io.tpetillot.hellograalvm.Main
Caused by: java.lang.ClassNotFoundException: io.tpetillot.hellograalvm.Main
From my understanding, produced executable include everything needed (with exception for classes access through reflection).
Here i'm running a simple hello world.
As it's my first steps with GraalVM and native images, I'm surely missing something?
Information
- sbt-native-packager version 1.9.16
- SBT version: 1.8.2
- OS: Windows 11 (Version 22H2 OS Build 22621.155)
- GraalVM Native image
It work with option --report-unsupported-elements-at-runtime. But I cannot understand why:
-report-unsupported-elements-at-runtime: report the usage of unsupported methods and fields at runtime when they are accessed the first time, instead of an error during an image building.
I did not get an error during image building, but when executing elsewhere than where it was...
--no-fallback also works, but I don't get the underlying reason aswell.