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

GraalVM native binary throws java.lang.NoSuchMethodException #7630

Closed
miguelaferreira opened this issue Jul 2, 2022 · 9 comments
Closed

Comments

@miguelaferreira
Copy link
Contributor

Expected Behavior

I've built an example cli application that uses a java git library form the eclipse project called jGit. While I can build and execute the application from a jar, I cannot build a native binary that executes correctly.

Actual Behaviour

The native binary does not execute as the jar does, and throws the following exception:

22:57:00.517 [main] INFO  i.m.context.env.DefaultEnvironment - Established active environments: [cli]
Exception in thread "main" java.lang.Error: java.lang.NoSuchMethodException: org.eclipse.jgit.internal.JGitText.<init>()
        at org.eclipse.jgit.nls.GlobalBundleCache.lookupBundle(GlobalBundleCache.java:70)
        at org.eclipse.jgit.nls.NLS.get(NLS.java:125)
        at org.eclipse.jgit.nls.NLS.getBundleFor(NLS.java:101)
        at org.eclipse.jgit.internal.JGitText.get(JGitText.java:28)
        at org.eclipse.jgit.api.CloneCommand.verifyDirectories(CloneCommand.java:255)
        at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:166)
        at cli.app.latest.CliAppLatestCommand.clone(CliAppLatestCommand.java:53)
        at cli.app.latest.CliAppLatestCommand.run(CliAppLatestCommand.java:36)
        at picocli.CommandLine.executeUserObject(CommandLine.java:1939)
        at picocli.CommandLine.access$1300(CommandLine.java:145)
        at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2358)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2352)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2314)
        at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2179)
        at picocli.CommandLine$RunLast.execute(CommandLine.java:2316)
        at picocli.CommandLine.execute(CommandLine.java:2078)
        at io.micronaut.configuration.picocli.PicocliRunner.run(PicocliRunner.java:137)
        at io.micronaut.configuration.picocli.PicocliRunner.run(PicocliRunner.java:114)
        at cli.app.latest.CliAppLatestCommand.main(CliAppLatestCommand.java:28)
Caused by: java.lang.NoSuchMethodException: org.eclipse.jgit.internal.JGitText.<init>()
        at java.lang.Class.getConstructor0(DynamicHub.java:3585)
        at java.lang.Class.getDeclaredConstructor(DynamicHub.java:2754)
        at org.eclipse.jgit.nls.GlobalBundleCache.lookupBundle(GlobalBundleCache.java:63)
        ... 18 more

Steps To Reproduce

  1. Clone the example application git clone https://github.com/miguelaferreira/issue-micronaut-graalvm-jgit.git
  2. Build the native binary ./gradlew nativeCompile
  3. Execute the native binary build/native/nativeCompile/cli-app-latest

Environment Information

  • Operating System: macOS Monterey 12.4 (21F79)
  • JDK: GraalVM 22.0.0.2.r17

Example Application

https://github.com/miguelaferreira/issue-micronaut-graalvm-jgit

Version

3.5.2

@miguelaferreira miguelaferreira changed the title GraalVM native binary for cli app throws java.lang.NoSuchMethodException GraalVM native binary throws java.lang.NoSuchMethodException Jul 2, 2022
@yawkat
Copy link
Member

yawkat commented Jul 4, 2022

Graal requires configuration to be able to use reflection, which jgit appears to do: https://docs.oracle.com/en/graalvm/enterprise/20/docs/reference-manual/native-image/Reflection/ – this is unfortunately not trivial, it's hard to say if it's feasible for jgit.

Closing since this is a graal/jgit issue, nothing we can do about that (except add our own jgit integration)

@yawkat yawkat closed this as not planned Won't fix, can't repro, duplicate, stale Jul 4, 2022
@miguelaferreira
Copy link
Contributor Author

Thanks for getting back to me @yawkat.

I understand that Graal needs configuration for reflection, and from this discussion on another issue, I got the impression that micronaut would be responsible for fully configuring the native image compilation, and that users shouldn't try to add their own configuration.

What I don't follow from your message is this bit

... which jgit appears to do

What is jGit doing?

@yawkat
Copy link
Member

yawkat commented Jul 4, 2022

No, micronaut does not (cannot) produce the reflection config for third-party libraries that we don't explicitly add support for.

jgit is using reflection.

@miguelaferreira
Copy link
Contributor Author

Alright! Thanks.

@dstepanov
Copy link
Contributor

You can use TypeHint annotation in combination with annotation processor dependency micronaut-graal to add those entries using an annotation.

@alvarosanchez
Copy link
Member

You can also run the JAR with GraalVM and enable the tracing agent

@miguelaferreira
Copy link
Contributor Author

@alvarosanchez Would I then need to merge the configuration the tracer agent generates with the configuration that micronaut generates under build/classes/java/main/META-INF/native-image/picocli-generated?

@alvarosanchez
Copy link
Member

What I would do is to isolate jgit in a standalone project with no Micronaut dependencies, and use the GraalVM agent in there.

@miguelaferreira
Copy link
Contributor Author

Alright, thanks!

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

4 participants