It would be nice to perform analysis of AOT processing failures in the same way as we do for failures during application startup. I've prototyped something as a proof of concept but it's still quite rough around the edges. There's a fair amount of copy-paste between SpringApplicationAotProcessor and SpringApplication. The resulting output also says APPLICATION FAILED TO START which is misleading for an AOT processing failure:
> Task :greetings-app:processAot FAILED
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v3.0.0-SNAPSHOT)
2022-11-16T20:30:59.271Z INFO 80763 --- [ main] com.example.greetings.Application : Starting Application using Java 17.0.5 with PID 80763 (/Users/awilkinson/dev/temp/spring-native-multi-modules-bind-properties/greetings-app/build/classes/java/main started by awilkinson in /Users/awilkinson/dev/temp/spring-native-multi-modules-bind-properties/greetings-app)
2022-11-16T20:30:59.276Z INFO 80763 --- [ main] com.example.greetings.Application : No active profile set, falling back to 1 default profile: "default"
2022-11-16T20:30:59.920Z ERROR 80763 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Constructor binding in a native image requires compilation with -parameters but the following classes were compiled without it:
com.example.greetings.configuration.GreetingsProperties
Action:
Recompile the classes with -parameters
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':greetings-app:processAot'.
> Process 'command '/Library/Java/LibericaNativeImageKit/liberica-vm-core-22.3.0-openjdk17/Contents/Home/bin/java'' finished with non-zero exit value 1
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 3s
6 actionable tasks: 6 executed
I'm also not sure about reusing the FailureAnalyzer contract as it means that the AOT-specific analysers will be available at runtime which feels a bit wasteful if we end up with several of them.
Comment From: nhandev552
How to fix this issue. I aslo get this with mongock:
Exception in thread "main" org.springframework.boot.context.properties.bind.MissingParametersCompilerArgumentException: Constructor binding in a native image requires compilation with -parameters but the following classes were compiled without it:
io.mongock.driver.mongodb.springdata.v4.config.MongoDBConfiguration$WriteConcernLevel
Comment From: wilkinsona
@nhandev552 We prefer questions to be asked on Stack Overflow.