0

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).

  • 1
    Try to narrow the stack trace a little bit more and the correct tag for spring native is "spring-native". Consider removing both "native" and "spring" as tag as this is specific to spring antive. – Stefan Norberg Aug 18 '22 at 21:30
  • 1
    Thank you very much for the answers! They really helped me. It worked fine the solution from @joery-vreijsen. – user6354846 Aug 22 '22 at 09:39

2 Answers2

1

This error has suddenly started appearing recently on all projects (without making any changes) which were building fine with

spring-boot:build-image.
n4321d
  • 1,059
  • 2
  • 12
  • 31
Amit Pad
  • 11
  • 1
1

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.