Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Native image executable: could not find or load main class #1544

Open
tpetillot opened this issue Apr 28, 2023 · 1 comment
Open

Native image executable: could not find or load main class #1544

tpetillot opened this issue Apr 28, 2023 · 1 comment

Comments

@tpetillot
Copy link

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
@tpetillot
Copy link
Author

tpetillot commented Apr 28, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant