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

The cli application does not work as a native image on GraalVM #2007

Open
seanzxx opened this issue Aug 11, 2023 · 1 comment
Open

The cli application does not work as a native image on GraalVM #2007

seanzxx opened this issue Aug 11, 2023 · 1 comment

Comments

@seanzxx
Copy link

seanzxx commented Aug 11, 2023

Description

The cli application does not work as a native image on GraalVM.

Steps to Reproduce

  1. mn create-cli-app cliapp --features graalvm --build=gradle --lang=kotlin
  2. cd cliapp
  3. ./gradlew -q clean nativeRun

Expected Behaviour

The example exits without any output

Actual Behaviour

The example ends up with Exception:

picocli.CommandLine$InitializationException: Cannot instantiate cliapp.CliappCommand: the class has no constructor
        at picocli.CommandLine$DefaultFactory.create(CommandLine.java:5685)
        at picocli.CommandLine$Model$CommandUserObject.getInstance(CommandLine.java:12263)
        at picocli.CommandLine$Model$CommandSpec.userObject(CommandLine.java:6437)
        at picocli.CommandLine$Interpreter.clear(CommandLine.java:13497)
        at picocli.CommandLine$Interpreter.parse(CommandLine.java:13543)
        at picocli.CommandLine$Interpreter.parse(CommandLine.java:13532)
        at picocli.CommandLine$Interpreter.parse(CommandLine.java:13427)
        at picocli.CommandLine.parseArgs(CommandLine.java:1552)
        at picocli.CommandLine.execute(CommandLine.java:2169)
        at io.micronaut.configuration.picocli.PicocliRunner.run(PicocliRunner.java:137)
        at io.micronaut.configuration.picocli.PicocliRunner.run(PicocliRunner.java:114)
        at cliapp.CliappCommand$Companion.main(CliappCommand.kt:27)
        at cliapp.CliappCommand.main(CliappCommand.kt)
Caused by: java.lang.NoSuchMethodException: cliapp.CliappCommand.<init>()
        at [email protected]/java.lang.Class.checkMethod(DynamicHub.java:1038)
        at [email protected]/java.lang.Class.getConstructor0(DynamicHub.java:1204)
        at [email protected]/java.lang.Class.getDeclaredConstructor(DynamicHub.java:2754)
        at picocli.CommandLine$DefaultFactory.create(CommandLine.java:5656)
        at io.micronaut.configuration.picocli.MicronautFactory.create(MicronautFactory.java:74)
        at picocli.CommandLine$DefaultFactory.create(CommandLine.java:5683)
        ... 12 more

Environment Information

  • Operating System: macOS
  • Micronaut Version: 4.0.3
  • JDK Version: Oracle GraalVM 17.0.8

Example Application

cliapp.tar.gz

@seanzxx
Copy link
Author

seanzxx commented Aug 11, 2023

The picocli-codegen is not working with the ksp yet.

remkop/picocli#1564

It works as expected after I use kapt instead.

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