Closed twobeeb closed 1 year ago
I came to understand that the error in 21.1.0 is unrelated micronaut-projects/micronaut-core#5655
So I focused to graalvm 21.3.0. I created a new project from micronaut launch in order to use the latest version of Micronaut (3.2.0) and micronaut plugin (3.0.0). https://github.com/twobeeb/demo/actions Each new commit tries to reduce the complexity of the project but no luck so far...
Thanks for your help
Ok so I found 2 issues that makes windows build fail:
Check the associated github actions to understand how I came to that conclusion. https://github.com/twobeeb/demo/actions As a reminder, the linux build was always successful for every workflow run
@twobeeb so you are saying it works on Linux but fails only on Windows?
@graemerocher precisely. Each commit on this project https://github.com/twobeeb/demo/ triggers the linux and windows workflows. As you can see, I managed to isolate 2 distinct elements that produce the same error :
In every failed workflow, the linux build was successful
I updated to micronaut plugin 3.0.1 this afternoon, and I was happy to see that the build is now successful.
Unfortunately, now every injected Singleton is returning NullPointerException in native-image builds on windows
Windows :
PS C:\Users\F297755\.kafkactl> .\kafkactl.exe
java.lang.NullPointerException
at com.michelin.ns4kafka.cli.KafkactlCommand.call(KafkactlCommand.java:63)
at com.michelin.ns4kafka.cli.KafkactlCommand.call(KafkactlCommand.java:13)
at picocli.CommandLine.executeUserObject(CommandLine.java:1953)
at picocli.CommandLine.access$1300(CommandLine.java:145)
at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2352)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2346)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2311)
at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2179)
at picocli.CommandLine.execute(CommandLine.java:2078)
at io.micronaut.configuration.picocli.PicocliRunner.execute(PicocliRunner.java:202)
at io.micronaut.configuration.picocli.PicocliRunner.execute(PicocliRunner.java:179)
at com.michelin.ns4kafka.cli.KafkactlCommand.main(KafkactlCommand.java:56)
Linux build:
julien@Julien-PC:$ ./kafkactl
v0.1
Usage: kafkactl [-hvV] [-n=<optionalNamespace>] [COMMAND]
-h, --help Show this help message and exit.
-n, --namespace=<optionalNamespace>
Override namespace defined in config or yaml resource
-v, --verbose ...
-V, --version Print version information and exit.
Commands:
apply Create or update a resource
get Get resources by resource type for the current namespace
delete Delete a resource
api-resources Print the supported API resources on the server
diff Get differences between the new resources and the old resource
reset-offsets Reset Consumer Group offsets
delete-records Deletes all records within a topic
import Import resources already present on the Kafka Cluster in
ns4kafka
connectors Interact with connectors (Pause/Resume/Restart)
This NullPointerException behavior is reproduced on the simplest possible CLI project : https://github.com/twobeeb/demo-http-cli
PS C:\Users\F297755\.kafkactl> .\kafkactl.exe> .\demo-http-cli.exe
←[36m22:32:12.449←[0;39m ←[1;30m[main]←[0;39m ←[34mINFO ←[0;39m ←[35mi.m.context.env.DefaultEnvironment←[0;39m - Established active environments: [cli]
java.lang.NullPointerException
at com.example.DemoHttpCliCommand.run(DemoHttpCliCommand.java:27)
at picocli.CommandLine.executeUserObject(CommandLine.java:1939)
at picocli.CommandLine.access$1300(CommandLine.java:145)
at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2352)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2346)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2311)
at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2179)
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 com.example.DemoHttpCliCommand.main(DemoHttpCliCommand.java:22)
@twobeeb going to investigate
Can you compare the contents of the build/native/generated/generateResourcesConfigFile/resource-config.json
file on Linux and Windows?
@twobeeb can you confirm whether the NPE only happens on Windows?
@graemerocher Confirmed. The issue is only on windows build (this error is network error, This VM doesn't have internet access, bit it clearly "worked")
[foundation@carsfkc01 ~]$ ./demo-http-cli
11:04:05.773 [main] INFO i.m.context.env.DefaultEnvironment - Established active environments: [cli]
11:04:16.806 [main] ERROR i.m.r.intercept.RecoveryInterceptor - Type [com.example.GithubClient$Intercepted] executed with error: Read Timeout
io.micronaut.http.client.exceptions.ReadTimeoutException: Read Timeout
io.micronaut.http.client.exceptions.ReadTimeoutException: Read Timeout
@melix my demo project contains the github action with the artifacts containing what you need : https://github.com/twobeeb/demo-http-cli/actions/runs/1528085284
Windows and Linux both have the following resource-config.json
{
"resources" : {
"includes" : [ ],
"excludes" : [ ]
},
"bundles" : [ ]
}
Hi @graemerocher @melix Just FYI, I reverted my project to micronaut 2.5.x. I discovered then that I can't build on windows with graalvm later than 20.3.x https://github.com/michelin/ns4kafka/blob/master/.github/workflows/on_push_master.yml linux build is fine on graalvm 21.1.0 I don't know if this information could be any help...
Hello, I'm having the same issue (NullPointerException on a injected singleton) with a project generated this week using the launcher
Hello, I faced the same issue: NullPointerException on an injected bean when running a Command Line App as Windows native executable.
Just instantiated a brand new project with:
However, it seems working when the project is built with Maven instead of Gradle.
Working: https://github.com/loicgreffier/micronaut-picocli-maven Not working: https://github.com/twobeeb/micronaut-issue-6595
The only difference is the build tool so the issue seems coming from the build with Gradle. Can anybody confirm ?
@alvarosanchez @melix could you investigate this for Windows for both Maven and Gradle
Hi! I confirm. Same problem.
Micronaut 3.3.3, Command Line Application GraalVM 22.0.0.2 Windows 10 Visual Studio Build Tools 2022 Gradle 7.4
I tested this issue again with:
There is no more injection issue for me, I can run both of my native Linux/Windows images as expected
Expected Behavior
I'm using native image to compile a Micronaut Picocli CLI for windows and linux
Following Upgrade :
Linux build is successful Windows build is failed
Actual Behaviour
This github actions shows the failure with micronaut 3.1.4 and graalvm 21.3.0 https://github.com/michelin/ns4kafka/actions/runs/1509108289
Successful linux and windows build from a previous build before migrating to Micronaut 3.1.4 https://github.com/michelin/ns4kafka/actions/runs/1491868428
The error:
Steps To Reproduce
No response
Environment Information
github actions are configured with latest windows and ubuntu images I'm using graalvm jdk 11 everywhere
Example Application
https://github.com/michelin/ns4kafka (original project) https://github.com/twobeeb/demo (simplified version)
Version
3.1.4