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

[Documentation] Note that resources in native executables should be loaded via getResourceAsStream #7813

Open
olsavmic opened this issue Nov 13, 2023 · 2 comments
Assignees
Labels

Comments

@olsavmic
Copy link

Feature request

I was working on switching a few of our applications to GraalVM native image and I spent significant time debugging why we're unable to load our classpath resources even though I followed the documentation (https://www.graalvm.org/22.1/reference-manual/native-image/Resources/).

All the logs from the compilation (with -H:Log=registerResource:3 flag) seemed to be correct yet the app was unable to load the resource.

The culprit was using ClassLoader.getResource("classpath").getFile() and then trying to read the file instead of calling ClassLoader.getResourceAsStream(). Yeah, it makes sense, the resource is inside a native executable, it's not a regular file... But it's not obvious without prior experience :)

Describe the solution you'd like.
Let's improve the documentation Adding resources to native image to mention that the resources are not regular files and should not be approached as such.

The same issue seems to have happened to other people (like #3092 (comment) or quarkusio/quarkus#2746 (comment) ) and although a solution was found, there was no clear explanation.

@kassifar
Copy link

Hello @olsavmic,
Thank you for your suggestion we will be taking a look at it shortly.

@kassifar kassifar self-assigned this Nov 14, 2023
@olsavmic
Copy link
Author

olsavmic commented Jun 4, 2024

ping @kassifar :)

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

No branches or pull requests

2 participants