-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[GR-53978] Class graph unable to load classes with GraalVM JDK21 #8884
Comments
Hi @anshu-zs, Thanks for reaching out to us! I wanted to let you know that there's a compatibility issue between ClassGraph and GraalVM. When compiling to Native Image with GraalVM, the JARs on the classpath are no longer available. This means that any metadata associated with resources in those files becomes invalid. |
Hi @selhagani Thank you for replying, So is there any workaround for this? |
Hi @anshu-zs, I understand your concern. Currently, there aren't any workarounds available for this situation. However, I'll take this opportunity to forward your feedback as a feature request to our team. Thank you for bringing this to our attention! |
One of our latest PRs should help with explaining what to do. We will also write a guide for this kind of cases for the next release. In this concrete case I would include |
Hi @vjovanov
Here is modified ClassScanner class
I am basically trying to print the result of scanResult.getClassesImplementing(IEngine.class) For version GraalVM CE 22.3.1, 22.3.3
PS: Observe the result stored in Scanner
For other versions (eg: graalvm-jdk-21.0.2+13.1)
|
The first error comes from the fact that the scanner pulled in native image classes. In later versions on GraalVM this should not happen. In the second snippet, the issue is that the used class loader does not see the classes from the application. Can you try to pass the |
I noticed that since upgrading to GraalVM for JDK 22, you've encountered a new error. The error message suggests using the 'onlyWith' field in the TargetClass annotation to make substitution active only when necessary. It might be beneficial to review how your substitution-related annotations are configured. To provide more specific assistance, I really need a concise reproducer for the issue. Thanks! |
@selhagani for which example? Can you post an error? |
Hi @vjovanov I tried adding classLoader to classgraph
and tried creating the native image using latest Graal VM: GraalVM CE 22.0.1+8.1, but still I got the Scanner as empty along with the error
|
Hey @vjovanov, apologies for the confusion! It seems I responded to the wrong issue that @anshu-zs has also shared and mentioned this issue in. My comment was meant for that issue not this one. Thanks for your understanding!
|
I looked into this and it seems that new ClassGraph().overrideClasspath("<image-builder-classpath>") and the results showed up. @olpaw do we have a way to fetch @anshu-zs I would try to ask a question on the |
sure @vjovanov , thanks for the help. please do let me know about the classgraph issue whenever you find anything |
Hi I am trying to initialize
ClassScanner
at build time, but it's not able to load classesHere is my classScanner:
ClassScanner usage
Here are the logs when I run the native image:
Here as u can see my scanResult shows empty array
When I run my application locally instead of running native image I get scanResult as
GraalVM version
GraalVM JDK 21
The text was updated successfully, but these errors were encountered: