I am trying to build a Spring Native application using buildpacks by following the instructions from: https://docs.spring.io/spring-native/docs/current/reference/htmlsingle/#getting-started
I changed Java version to 11 or 17 to avoid an error. Locally I have installed GraalVM v17 (22.2.0 and 22.3.0-dev).
When running mvn spring-boot:build-image I receive the following error related to BeanUtils:
[INFO] [creator] Fatal error: com.oracle.graal.pointsto.util.AnalysisError$ParsingError:
Error encountered while parsing
org.springframework.boot.SpringApplication.createSpringFactoriesInstances(java.lang.Class, java.lang.Class[], java.lang.ClassLoader, java.lang.Object[], java.util.Set)
[INFO] [creator] Parsing context:
[INFO] [creator] at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:439)
[INFO] [creator] at org.springframework.nativex.substitutions.boot.Target_SpringApplication.getSpringFactoriesInstances(Target_SpringApplication.java:173)
[INFO] [creator] at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:424) [INFO] [creator]
[INFO] [creator] at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.AnalysisError.parsingError(AnalysisError.java:152)
[INFO] [creator] at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlow.createFlowsGraph(MethodTypeFlow.java:104)
[...]
[INFO] [creator] Caused by: org.graalvm.compiler.java.BytecodeParser$BytecodeParserError:
com.oracle.graal.pointsto.constraints.UnresolvedElementException:
Discovered unresolved method during parsing:
org.springframework.beans.BeanUtils$KotlinDelegate.instantiateClass(java.lang.reflect.Constructor, java.lang.Object[]).
This error is reported at image build time because class
org.springframework.beans.BeanUtils is registered for linking at image build time by system default
[INFO] [creator] at parsing org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:196) [...]
[INFO] [creator] ... 13 more
[INFO] [creator] Caused by: com.oracle.graal.pointsto.constraints.UnresolvedElementException:
Discovered unresolved method during parsing:
org.springframework.beans.BeanUtils$KotlinDelegate.instantiateClass(java.lang.reflect.Constructor, java.lang.Object[]).
This error is reported at image build time because class
org.springframework.beans.BeanUtils is registered for
linking at image build time by system default
... 38 more
[INFO] [creator] --------------------------------------------------------------------------------
The build is working fine when using Native Build Tools. The .exe files executes correctly ( I am using Windows).
Seems like there is an issue with paketobuildpacks/builder:0.1.242-tiny which I also experienced in paketobuildpacks/builder:base.
Downgrading to 0.1.241-tiny seems to resolve the issue.
See paketo-buildpacks/native-image#176 for workarounds to this problem, and follow that issue for the resolution.