0

I am trying to use the Spring Boot plugin for Maven to build docker images. The project I'm working with is the Spring Boot REST service demo, so I'm using the provided mvnw script. The output I'm getting is this:

./mvnw spring-boot:build-image
...
...
...
[INFO]     [creator]     ================================================================================
[INFO]     [creator]     GraalVM Native Image: Generating '/layers/paketo-buildpacks_native-image/native-image/com.example.restservice.RestserviceApplication' (executable)...
[INFO]     [creator]     ================================================================================
[INFO]     [creator]     [1/7] Initializing...                                           (13.9s @ 0.19GB)
[INFO]     [creator]      Version info: 'GraalVM 22.3.0 Java 17 CE'
[INFO]     [creator]      Java version info: '17.0.5+8-LTS'
[INFO]     [creator]      C compiler: gcc (linux, x86_64, 7.5.0)
[INFO]     [creator]      Garbage collector: Serial GC
[INFO]     [creator]      1 user-specific feature(s)
[INFO]     [creator]      - org.springframework.aot.nativex.feature.PreComputeFieldFeature
[INFO]     [creator]     Field org.springframework.core.NativeDetector#imageCode set to true at build time
[INFO]     [creator]     Field org.apache.commons.logging.LogAdapter#log4jSpiPresent set to true at build time
[INFO]     [creator]     Field org.apache.commons.logging.LogAdapter#log4jSlf4jProviderPresent set to true at build time
[INFO]     [creator]     Field org.apache.commons.logging.LogAdapter#slf4jSpiPresent set to true at build time
[INFO]     [creator]     Field org.apache.commons.logging.LogAdapter#slf4jApiPresent set to true at build time
[INFO]     [creator]     Field org.springframework.core.KotlinDetector#kotlinPresent set to false at build time
[INFO]     [creator]     Field org.springframework.core.KotlinDetector#kotlinReflectPresent set to false at build time
[INFO]     [creator]     Field org.springframework.format.support.DefaultFormattingConversionService#jsr354Present set to false at build time
[INFO]     [creator]     Field org.springframework.cglib.core.AbstractClassGenerator#imageCode set to true at build time
[INFO]     [creator]     [2/7] Performing analysis...  [**********]                      (76.1s @ 1.20GB)
[INFO]     [creator]       10,216 (89.57%) of 11,406 classes reachable
[INFO]     [creator]       16,618 (63.42%) of 26,202 fields reachable
[INFO]     [creator]       48,432 (58.35%) of 83,000 methods reachable
[INFO]     [creator]          468 classes,   138 fields, and 2,281 methods registered for reflection
[INFO]     [creator]           63 classes,    68 fields, and    55 methods registered for JNI access
[INFO]     [creator]            4 native libraries: dl, pthread, rt, z
[INFO]     [creator]     [3/7] Building universe...                                       (8.0s @ 1.49GB)
[INFO]     [creator]     
[INFO]     [creator]     Warning: Dynamic proxy method java.lang.reflect.Proxy.newProxyInstance invoked at org.springframework.core.io.support.VfsPatternUtils.visit(VfsPatternUtils.java:51)
[INFO]     [creator]     Warning: Dynamic proxy method java.lang.reflect.Proxy.newProxyInstance invoked at org.springframework.beans.factory.support.AutowireUtils.resolveAutowiringValue(AutowireUtils.java:134)
[INFO]     [creator]     Warning: Dynamic proxy method java.lang.reflect.Proxy.newProxyInstance invoked at org.springframework.core.annotation.SynthesizedMergedAnnotationInvocationHandler.createProxy(SynthesizedMergedAnnotationInvocationHandler.java:304)
[INFO]     [creator]     Warning: Aborting stand-alone image build due to dynamic proxy use without configuration.
[INFO]     [creator]     Warning: Use -H:+ReportExceptionStackTraces to print stacktrace of underlying exception
[INFO]     [creator]     --------------------------------------------------------------------------------
[INFO]     [creator]         5.0s (5.0% of total time) in 27 GCs | Peak RSS: 3.45GB | CPU load: 4.45
[INFO]     [creator]     ================================================================================
[INFO]     [creator]     Failed generating '/layers/paketo-buildpacks_native-image/native-image/com.example.restservice.RestserviceApplication' after 1m 38s.
[INFO]     [creator]     Generating fallback image...
[INFO]     [creator]     Warning: Image '/layers/paketo-buildpacks_native-image/native-image/com.example.restservice.RestserviceApplication' is a fallback image that requires a JDK for execution (use --no-fallback to suppress fallback image generation and to print more detailed information why a fallback image was necessary).
...
...
...

We can see step 3/7 failed, and the builder went on to create a fallback image, which I haven't tested. My questions are as follows:

A) The output recommends trying -no-fallback to see the full error, but when I try mvnw spring-boot:build-image -no-fallback, the argument doesn't get passed along to spring/paketo. mvn fails because it doesn't have that option. How can I pass the argument to the spring plugin and/or the build pack?

B) Same question for the other recommendation to print the stack trace, -H:+ReportExceptionStackTraces

C) How can I troubleshoot/fix this issue?

codesling
  • 43
  • 6
  • Did you upgrade to Spring Boot 3 and upgraded all dependencies? The error seems to indicate you haven't (or are mixing things from different versions). So please add the pom you are actually using (and that isn't the pom from the guide you are referencing). – M. Deinum Jan 24 '23 at 08:21
  • @M.Deinum I never got the bottom of this issue but discovered my builder shouldn't have been using Graal to begin with. I had this line `true` under a plugin in the project's pom which was causing the use of paketo/Graal. Removing it let me build an image just fine. – codesling Jan 24 '23 at 15:49

0 Answers0