-
Notifications
You must be signed in to change notification settings - Fork 431
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
Pico CLI runtime issue on Graal 23 - picocli.CommandLine$InitializationException Cannot instantiate the class has no constructor #2357
Comments
This sounds like a bug in GraalVM 23, but just to double check, can you provide the contents of your |
I had that feeling as well, but wasn't sure. my graalvm config files looks like: [
{
"name": "nl.altindag.crip.command.CertificateRipper",
"allDeclaredConstructors": true,
"allPublicConstructors": true,
"allDeclaredMethods": true,
"allPublicMethods": true
},
{
"name": "nl.altindag.crip.command.SharedProperties",
"allDeclaredConstructors": true,
"allPublicConstructors": true,
"allDeclaredMethods": true,
"allPublicMethods": true,
"fields": [
{
"name": "urls"
},
{
"name": "proxyHost"
},
{
"name": "proxyPort"
},
{
"name": "proxyUser"
},
{
"name": "proxyPassword"
},
{
"name": "timeoutInMilliseconds"
},
{
"name": "resolveRootCa"
}
]
},
{
"name": "nl.altindag.crip.command.PrintCommand",
"allDeclaredConstructors": true,
"allPublicConstructors": true,
"allDeclaredMethods": true,
"allPublicMethods": true,
"fields": [
{
"name": "sharedProperties"
},
{
"name": "format"
}
]
},
{
"name": "nl.altindag.crip.command.export.ExportCommand",
"allDeclaredConstructors": true,
"allPublicConstructors": true,
"allDeclaredMethods": true,
"allPublicMethods": true
},
{
"name": "nl.altindag.crip.command.export.FileExport",
"allDeclaredConstructors": true,
"allPublicConstructors": true,
"allDeclaredMethods": true,
"allPublicMethods": true,
"fields": [
{
"name": "sharedProperties"
},
{
"name": "destination"
}
]
},
{
"name": "nl.altindag.crip.command.export.CombinableFileExport",
"allDeclaredConstructors": true,
"allPublicConstructors": true,
"allDeclaredMethods": true,
"allPublicMethods": true,
"fields": [
{
"name": "combined"
}
]
},
{
"name": "nl.altindag.crip.command.export.KeyStoreExportCommand",
"allDeclaredConstructors": true,
"allPublicConstructors": true,
"allDeclaredMethods": true,
"allPublicMethods": true,
"fields": [
{
"name": "password"
}
]
},
{
"name": "nl.altindag.crip.command.export.Pkcs12ExportCommand",
"allDeclaredConstructors": true,
"allPublicConstructors": true,
"allDeclaredMethods": true,
"allPublicMethods": true
},
{
"name": "nl.altindag.crip.command.export.JavaKeyStoreExportCommand",
"allDeclaredConstructors": true,
"allPublicConstructors": true,
"allDeclaredMethods": true,
"allPublicMethods": true
},
{
"name": "nl.altindag.crip.command.export.DerExportCommand",
"allDeclaredConstructors": true,
"allPublicConstructors": true,
"allDeclaredMethods": true,
"allPublicMethods": true
},
{
"name": "nl.altindag.crip.command.export.PemExportCommand",
"allDeclaredConstructors": true,
"allPublicConstructors": true,
"allDeclaredMethods": true,
"allPublicMethods": true,
"fields": [
{
"name": "includeHeader"
}
]
}
] I also attempted to add: {
"name": "nl.altindag.crip.command.VersionProvider",
"allDeclaredConstructors": true,
"allPublicConstructors": true,
"allDeclaredMethods": true,
"allPublicMethods": true
} However that resulted in
|
Created an issue at the graal github repo: |
In addition to adding {
"name": "nl.altindag.crip.command.VersionProvider",
"allDeclaredConstructors": true,
"allPublicConstructors": true,
"allDeclaredMethods": true,
"allPublicMethods": true
} Can you also try adding this? {
"name" : "picocli.CommandLine$AutoHelpMixin",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"fields" : [
{ "name" : "helpRequested" },
{ "name" : "versionRequested" }
]
} These should have been added by the picocli annotation processor. This may be a bug in the picocli annotation processor. |
This did the trick, amazing that you figured it out! Any idea why this issue is popping up with GraalVM 23? and not on version 22? |
Hi @remkop I am wondering what would be the proper follow up. So is this something you can fix on your side in the library? Or do you think I should just update the json property for graal on my side in my project and close this issue as well as the issue on graal project? |
From the GraalVM point of view, it is strange that the configuration works in Graal 22 but not on Graal 23. So that may still be interesting for the GraalVM team to look at. You may want to give them the info that we got it to work in Graal 23 by adding this extra config; question is why did it not fail in Graal 22? Then, from the picocli point of view, I need to spend time creating a test in (If anyone volunteers to track this down and provide a fix, that would be awesome.) |
Indeed if it works on graalvm 22 then it should also have worked on version 23. I will update them with the new finding.
I would like to give it a shot, let me see whether I can figure it out. |
I found the issue... And it was not related to your library. The codegen works correct. I was just manually creating my graalvm_config.json file and updating also manually. By adding the versionprovider and also the help function in the code I didn't added that part in the graalvm config json file as I didn't knew it was needed. I went through the documentation of picocli-codegen to understand how it works here. I made the adjustments to my project in this PR: Hakky54/certificate-ripper#57 The generated reflec-configt.json looks like: Generated GraalVM config file[
{
"name" : "java.lang.Boolean",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true
},
{
"name" : "java.lang.Integer",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true
},
{
"name" : "java.util.Collections$UnmodifiableRandomAccessList",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true
},
{
"name" : "nl.altindag.crip.command.CertificateRipper",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true
},
{
"name" : "nl.altindag.crip.command.PrintCommand",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"fields" : [
{ "name" : "format" },
{ "name" : "sharedProperties" }
]
},
{
"name" : "nl.altindag.crip.command.PrintCommand$Format",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true
},
{
"name" : "nl.altindag.crip.command.SharedProperties",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"fields" : [
{ "name" : "proxyHost" },
{ "name" : "proxyPassword" },
{ "name" : "proxyPort" },
{ "name" : "proxyUser" },
{ "name" : "resolveRootCa" },
{ "name" : "timeoutInMilliseconds" },
{ "name" : "urls" }
]
},
{
"name" : "nl.altindag.crip.command.VersionProvider",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true
},
{
"name" : "nl.altindag.crip.command.export.CombinableFileExport",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"fields" : [
{ "name" : "combined" }
]
},
{
"name" : "nl.altindag.crip.command.export.DerExportCommand",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true
},
{
"name" : "nl.altindag.crip.command.export.ExportCommand",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true
},
{
"name" : "nl.altindag.crip.command.export.FileExport",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"fields" : [
{ "name" : "destination" },
{ "name" : "sharedProperties" }
]
},
{
"name" : "nl.altindag.crip.command.export.JavaKeyStoreExportCommand",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true
},
{
"name" : "nl.altindag.crip.command.export.KeyStoreExportCommand",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"fields" : [
{ "name" : "password" }
]
},
{
"name" : "nl.altindag.crip.command.export.PemExportCommand",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"fields" : [
{ "name" : "includeHeader" }
]
},
{
"name" : "nl.altindag.crip.command.export.Pkcs12ExportCommand",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true
},
{
"name" : "picocli.CommandLine$AutoHelpMixin",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"fields" : [
{ "name" : "helpRequested" },
{ "name" : "versionRequested" }
]
}
] I still find it strange that my manually created config file is working with graalvm 22 and not anymore with graalvm 23. But that is something which I will share with the graal vm developers. I created the native executable with graalvm 23 and it works. I think we can close this issue as there is no issue at all with picocli., wdyt? |
Oh 😅 phew, that is good to hear! Yes, happy to close if there's no issue with picocli-codegen. |
I noticed that Pico CLI is working on Graal 22 but not on Graal 23 anymore when creating/running a native image. I wasn't quite sure where to create this issue as I am not sure where it could be fixed. So I was in doubt whether Graal has caused an issue and has regression. I wanted to raise this issue first here as you are the library maintainer and maybe can easily find the issue and if it is caused by the Graal changes itself we can provide context to them to resolve it on their side if that is the case.
I am using Pico CLI alongside with Graal to create a native image for Certificate Ripper. Recently I added
VersionProvider
class which implementsCommandLine.IVersionProvider
to provide the version. On Graal 22 this works, however on version 23 it gives me the following error:How to reproduce?
git clone https://github.com/Hakky54/certificate-ripper.git
mvn clean install -Pnative-image
./target/crip
(it does not give a runtime exception)Any idea what the root cause could be? Adding a default constructor to the VersionProvider did not work.
The text was updated successfully, but these errors were encountered: