Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring Boot Native image builds with 22.2.0 are failing #176

Closed
dmikusa opened this issue Aug 19, 2022 · 18 comments · Fixed by #177
Closed

Spring Boot Native image builds with 22.2.0 are failing #176

dmikusa opened this issue Aug 19, 2022 · 18 comments · Fixed by #177
Labels
type:bug A general bug

Comments

@dmikusa
Copy link
Contributor

dmikusa commented Aug 19, 2022

Expected Behavior

Build of a Spring Boot application with Liberica NIK 22.2.0 succeeds.

Current Behavior

Build of a Spring Boot application with Liberica NIK 22.2.0 fails with the following error:

Paketo Native Image Buildpack 5.2.5
  https://github.com/paketo-buildpacks/native-image
  Build Configuration:
    $BP_BINARY_COMPRESSION_METHOD                Compression mechanism used to reduce binary size. Options: `none` (default), `upx` or `gzexe`
    $BP_NATIVE_IMAGE                       true  enable native image build
    $BP_NATIVE_IMAGE_BUILD_ARGUMENTS             arguments to pass to the native-image command
    $BP_NATIVE_IMAGE_BUILD_ARGUMENTS_FILE        a file with arguments to pass to the native-image command
    $BP_NATIVE_IMAGE_BUILT_ARTIFACT              the built application artifact explicitly, required if building from a JAR
  Native Image: Contributing to layer
    Executing native-image -H:Name=/layers/paketo-buildpacks_native-image/native-image/io.paketo.demo.DemoApplication -cp /workspace:/workspace/BOOT-INF/classes:/workspace/BOOT-INF/lib/spring-boot-2.7.2.jar:/workspace/BOOT-INF/lib/spring-context-5.3.22.jar:/workspace/BOOT-INF/lib/spring-aop-5.3.22.jar:/workspace/BOOT-INF/lib/spring-expression-5.3.22.jar:/workspace/BOOT-INF/lib/spring-boot-autoconfigure-2.7.2.jar:/workspace/BOOT-INF/lib/logback-classic-1.2.11.jar:/workspace/BOOT-INF/lib/logback-core-1.2.11.jar:/workspace/BOOT-INF/lib/log4j-to-slf4j-2.17.2.jar:/workspace/BOOT-INF/lib/log4j-api-2.17.2.jar:/workspace/BOOT-INF/lib/jul-to-slf4j-1.7.36.jar:/workspace/BOOT-INF/lib/jakarta.annotation-api-1.3.5.jar:/workspace/BOOT-INF/lib/snakeyaml-1.30.jar:/workspace/BOOT-INF/lib/jackson-databind-2.13.3.jar:/workspace/BOOT-INF/lib/jackson-annotations-2.13.3.jar:/workspace/BOOT-INF/lib/jackson-core-2.13.3.jar:/workspace/BOOT-INF/lib/jackson-datatype-jdk8-2.13.3.jar:/workspace/BOOT-INF/lib/jackson-datatype-jsr310-2.13.3.jar:/workspace/BOOT-INF/lib/jackson-module-parameter-names-2.13.3.jar:/workspace/BOOT-INF/lib/reactor-netty-http-1.0.21.jar:/workspace/BOOT-INF/lib/netty-codec-http-4.1.79.Final.jar:/workspace/BOOT-INF/lib/netty-common-4.1.79.Final.jar:/workspace/BOOT-INF/lib/netty-buffer-4.1.79.Final.jar:/workspace/BOOT-INF/lib/netty-transport-4.1.79.Final.jar:/workspace/BOOT-INF/lib/netty-codec-4.1.79.Final.jar:/workspace/BOOT-INF/lib/netty-handler-4.1.79.Final.jar:/workspace/BOOT-INF/lib/netty-codec-http2-4.1.79.Final.jar:/workspace/BOOT-INF/lib/netty-resolver-dns-4.1.79.Final.jar:/workspace/BOOT-INF/lib/netty-resolver-4.1.79.Final.jar:/workspace/BOOT-INF/lib/netty-codec-dns-4.1.79.Final.jar:/workspace/BOOT-INF/lib/netty-resolver-dns-native-macos-4.1.79.Final-osx-x86_64.jar:/workspace/BOOT-INF/lib/netty-resolver-dns-classes-macos-4.1.79.Final.jar:/workspace/BOOT-INF/lib/netty-transport-native-epoll-4.1.79.Final-linux-x86_64.jar:/workspace/BOOT-INF/lib/netty-transport-native-unix-common-4.1.79.Final.jar:/workspace/BOOT-INF/lib/netty-transport-classes-epoll-4.1.79.Final.jar:/workspace/BOOT-INF/lib/reactor-netty-core-1.0.21.jar:/workspace/BOOT-INF/lib/netty-handler-proxy-4.1.79.Final.jar:/workspace/BOOT-INF/lib/netty-codec-socks-4.1.79.Final.jar:/workspace/BOOT-INF/lib/spring-web-5.3.22.jar:/workspace/BOOT-INF/lib/spring-beans-5.3.22.jar:/workspace/BOOT-INF/lib/spring-webflux-5.3.22.jar:/workspace/BOOT-INF/lib/spring-native-0.12.1.jar:/workspace/BOOT-INF/lib/slf4j-api-1.7.36.jar:/workspace/BOOT-INF/lib/spring-core-5.3.22.jar:/workspace/BOOT-INF/lib/spring-jcl-5.3.22.jar:/workspace/BOOT-INF/lib/reactor-core-3.4.21.jar:/workspace/BOOT-INF/lib/reactive-streams-1.0.4.jar:/workspace/BOOT-INF/lib/spring-boot-jarmode-layertools-2.7.2.jar io.paketo.demo.DemoApplication
Warning: Using a deprecated option --allow-incomplete-classpath from 'META-INF/native-image/org.springframework.aot/spring-aot/native-image.properties' in 'file:///workspace/'. Allowing an incomplete classpath is now the default. Use --link-at-build-time to report linking errors at image build time for a class or package.
WARNING: Unknown module: org.graalvm.nativeimage.llvm specified to --add-exports
WARNING: Unknown module: org.graalvm.nativeimage.llvm specified to --add-exports
WARNING: Unknown module: org.graalvm.nativeimage.llvm specified to --add-exports
================================================================================
GraalVM Native Image: Generating '/layers/paketo-buildpacks_native-image/native-image/io.paketo.demo.DemoApplication' (executable)...
================================================================================
Warning: Could not register org.springframework.boot.autoconfigure.jdbc.HikariDriverConfigurationFailureAnalyzer: allDeclaredConstructors for reflection. Reason: java.lang.NoClassDefFoundError: org/springframework/jdbc/CannotGetJdbcConnectionException.
Warning: Could not register org.springframework.boot.autoconfigure.web.reactive.function.client.ClientHttpConnectorConfiguration$JettyClient: allDeclaredMethods for reflection. Reason: java.lang.NoClassDefFoundError: org/eclipse/jetty/util/ssl/SslContextFactory.
Warning: Could not register org.springframework.boot.diagnostics.analyzer.ValidationExceptionFailureAnalyzer: allDeclaredConstructors for reflection. Reason: java.lang.NoClassDefFoundError: javax/validation/ValidationException.
Warning: Could not register org.springframework.boot.liquibase.LiquibaseChangelogMissingFailureAnalyzer: allDeclaredConstructors for reflection. Reason: java.lang.NoClassDefFoundError: liquibase/exception/ChangeLogParseException.
Warning: Could not register org.springframework.boot.autoconfigure.jdbc.HikariDriverConfigurationFailureAnalyzer: allDeclaredConstructors for reflection. Reason: java.lang.NoClassDefFoundError: org/springframework/jdbc/CannotGetJdbcConnectionException.
Warning: Could not register org.springframework.boot.autoconfigure.web.reactive.function.client.ClientHttpConnectorConfiguration$JettyClient: allDeclaredMethods for reflection. Reason: java.lang.NoClassDefFoundError: org/eclipse/jetty/util/ssl/SslContextFactory.
Warning: Could not register org.springframework.boot.diagnostics.analyzer.ValidationExceptionFailureAnalyzer: allDeclaredConstructors for reflection. Reason: java.lang.NoClassDefFoundError: javax/validation/ValidationException.
Warning: Could not register org.springframework.boot.liquibase.LiquibaseChangelogMissingFailureAnalyzer: allDeclaredConstructors for reflection. Reason: java.lang.NoClassDefFoundError: liquibase/exception/ChangeLogParseException.
[1/7] Initializing...                                            (8.8s @ 0.38GB)
 Version info: 'GraalVM 22.2.0 Java 11 CE'
 Java version info: '11.0.16+8-LTS'
 C compiler: gcc (linux, x86_64, 7.5.0)
 Garbage collector: Serial GC
[2/7] Performing analysis...  []                                 (3.9s @ 0.74GB)
   1,385 (62.84%) of  2,204 classes reachable
     996 (38.00%) of  2,621 fields reachable
   4,240 (55.07%) of  7,699 methods reachable
     294 classes,     0 fields, and     0 methods registered for reflection
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)
Parsing context:
   at app//org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:439)
   at app//org.springframework.nativex.substitutions.boot.Target_SpringApplication.getSpringFactoriesInstances(Target_SpringApplication.java:173)
   at app//org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:424)
    at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.AnalysisError.parsingError(AnalysisError.java:152)
    at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlow.createFlowsGraph(MethodTypeFlow.java:104)
    at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlow.ensureFlowsGraphCreated(MethodTypeFlow.java:83)
    at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlow.getOrCreateMethodFlowsGraph(MethodTypeFlow.java:65)
    at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.typestate.DefaultSpecialInvokeTypeFlow.onObservedUpdate(DefaultSpecialInvokeTypeFlow.java:61)
    at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.TypeFlow.update(TypeFlow.java:558)
    at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.PointsToAnalysis$1.run(PointsToAnalysis.java:635)
    at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.CompletionExecutor.executeCommand(CompletionExecutor.java:193)
    at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.CompletionExecutor.lambda$executeService$0(CompletionExecutor.java:177)
    at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1426)
    at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
    at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
    at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
    at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
    at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
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
    at parsing app//org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:196)
    at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.throwParserError(BytecodeParser.java:2506)
    at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.throwParserError(SharedGraphBuilderPhase.java:105)
    at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.iterateBytecodesForBlock(BytecodeParser.java:3367)
    at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.handleBytecodeBlock(BytecodeParser.java:3319)
    at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.processBlock(BytecodeParser.java:3164)
    at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.build(BytecodeParser.java:1138)
    at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.buildRootMethod(BytecodeParser.java:1030)
    at jdk.internal.vm.compiler/org.graalvm.compiler.java.GraphBuilderPhase$Instance.run(GraphBuilderPhase.java:84)
    at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase.run(SharedGraphBuilderPhase.java:79)
    at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.run(Phase.java:49)
    at jdk.internal.vm.compiler/org.graalvm.compiler.phases.BasePhase.apply(BasePhase.java:261)
    at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.apply(Phase.java:42)
    at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.apply(Phase.java:38)
    at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.AnalysisParsedGraph.parseBytecode(AnalysisParsedGraph.java:135)
    at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisMethod.ensureGraphParsed(AnalysisMethod.java:685)
    at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.phases.InlineBeforeAnalysisGraphDecoder.lookupEncodedGraph(InlineBeforeAnalysis.java:180)
    at jdk.internal.vm.compiler/org.graalvm.compiler.replacements.PEGraphDecoder.doInline(PEGraphDecoder.java:1162)
    at jdk.internal.vm.compiler/org.graalvm.compiler.replacements.PEGraphDecoder.tryInline(PEGraphDecoder.java:1145)
    at jdk.internal.vm.compiler/org.graalvm.compiler.replacements.PEGraphDecoder.trySimplifyInvoke(PEGraphDecoder.java:1003)
    at jdk.internal.vm.compiler/org.graalvm.compiler.replacements.PEGraphDecoder.handleInvoke(PEGraphDecoder.java:957)
    at jdk.internal.vm.compiler/org.graalvm.compiler.nodes.GraphDecoder.processNextNode(GraphDecoder.java:817)
    at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.phases.InlineBeforeAnalysisGraphDecoder.processNextNode(InlineBeforeAnalysis.java:240)
    at jdk.internal.vm.compiler/org.graalvm.compiler.nodes.GraphDecoder.decode(GraphDecoder.java:548)
    at jdk.internal.vm.compiler/org.graalvm.compiler.replacements.PEGraphDecoder.decode(PEGraphDecoder.java:833)
    at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.phases.InlineBeforeAnalysis.decodeGraph(InlineBeforeAnalysis.java:98)
    at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.parse(MethodTypeFlowBuilder.java:176)
    at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.apply(MethodTypeFlowBuilder.java:343)
    at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlow.createFlowsGraph(MethodTypeFlow.java:93)
    ... 13 more
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
    at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.reportUnresolvedElement(SharedGraphBuilderPhase.java:298)
    at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.handleUnresolvedMethod(SharedGraphBuilderPhase.java:288)
    at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.handleUnresolvedInvoke(SharedGraphBuilderPhase.java:244)
    at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.genInvokeStatic(BytecodeParser.java:1664)
    at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.genInvokeStatic(BytecodeParser.java:1639)
    at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.processBytecode(BytecodeParser.java:5224)
    at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.iterateBytecodesForBlock(BytecodeParser.java:3359)
    ... 38 more
--------------------------------------------------------------------------------
    1.0s (7.1% of total time) in 13 GCs | Peak RSS: 1.17GB | CPU load: 4.10
================================================================================
Failed generating '/layers/paketo-buildpacks_native-image/native-image/io.paketo.demo.DemoApplication' after 13.0s.
Error: Image build request failed with exit status 1
unable to invoke layer creator
unable to contribute native-image layer
error running build
exit status 1
ERROR: failed to build: exit status 1
ERROR: failed to build: executing lifecycle: failed with status code: 51

Possible Solution

There are presently two workarounds. The first workaround is recommended, unless you cannot use it for some reason.

  1. Set USE_NATIVE_IMAGE_JAVA_PLATFORM_MODULE_SYSTEM=false. You can do that with pack build demo -e USE_NATIVE_IMAGE_JAVA_PLATFORM_MODULE_SYSTEM=false or with the following change in pom.xml.
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <configuration>
          <classifier>${repackage.classifier}</classifier>
          <image>
            <builder>paketobuildpacks/builder:tiny</builder>
            <env>
              <BP_NATIVE_IMAGE>true</BP_NATIVE_IMAGE>
              <USE_NATIVE_IMAGE_JAVA_PLATFORM_MODULE_SYSTEM>false</USE_NATIVE_IMAGE_JAVA_PLATFORM_MODULE_SYSTEM>
            </env>
          </image>
        </configuration>
      </plugin>
  1. Downgrade your buildpack. You can downgrade the buildpack by setting pack build demo -b gcr.io/paketo-buildpacks/java:6.34.0, or make this change in your pom.xml:
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <configuration>
          <classifier>${repackage.classifier}</classifier>
          <image>
            <builder>paketobuildpacks/builder:tiny</builder>
            <env>
              <BP_NATIVE_IMAGE>true</BP_NATIVE_IMAGE>
            </env>
            <buildpacks>
               <buildpack>gcr.io/paketo-buildpacks/java:6.34.0</buildpack>
            </buildpacks>
          </image>
        </configuration>
      </plugin>

Steps to Reproduce

  1. Download app from https://start.spring.io with WebFlux, Spring Native + Actuators.
  2. ./mvnw spring-boot:build-image or pack build demo -e BP_NATIVE_IMAGE=true.

Motivations

Impact: this is breaking builds for anyone using the latest builders or buildpack.

@pivotal-david-osullivan
Copy link
Contributor

The latest release of this buildpack (v5.3.1) sets the environment variable USE_NATIVE_IMAGE_JAVA_PLATFORM_MODULE_SYSTEM mentioned above to false automatically, as a workaround for this issue, until a permanent upstream fix is determined. Users can still set this manually if they wish to override the value to true.

The composite buildpack release java-native-image v7.27.1 contains this updated version & the workaround.

@iuliana
Copy link

iuliana commented Sep 12, 2022

I've had a similar issue on Apple M1 Pro. Initially I though the process hanged at step [1/7] Initializing..., but it was just unbearably slow. After downgrading the buildpacks as @dmikusa suggested the image was created.

@pivotal-david-osullivan
Copy link
Contributor

Update on this - the latest (dev) builds of GraalVM CE 22.3 do not seem to produce this error: https://github.com/graalvm/graalvm-ce-dev-builds/releases

The GraalVM team have confirmed that the USE_NATIVE_IMAGE_JAVA_PLATFORM_MODULE_SYSTEM will not be removed before 22.3 so once we are sure the error is no longer seen with 22.3+, we should not see this issue again.

@abelsromero
Copy link

Apologies in advance for the tangential topic, but I am struggling with a Kotlin compilation issue that's also supposed to be fixed in 22.3 and I am wondering if the GraalVM version could be finally bumped.

@dmikusa
Copy link
Contributor Author

dmikusa commented Dec 10, 2022

@abelsromero The latest Bellsoft Liberica & Graalvm buildpacks are shipping 22.3, so you should not see the error mentioned on this ticket (both because of that, but because we are also automatically setting the previously mentioned env variable that works around this issue).

If you're not getting 22.3, check and make sure you've got the latest builder & buildpack

@dmikusa
Copy link
Contributor Author

dmikusa commented Dec 10, 2022

@iuliana

I've had a similar issue on Apple M1 Pro. Initially I though the process hanged at step [1/7] Initializing..., but it was just unbearably slow. After downgrading the buildpacks as @dmikusa suggested the image was created.

This particular error shouldn't have caused slowness & I'm not sure why downgrading would impact what you're seeing there. That could be something else.

What I can say is that building with the buildpacks on an M1 Mac is that it's slower. It is especially slow when doing native-image builds because they are very CPU intensive. This is because the present set of buildpacks is not published with ARM64 images thus your Mac & Docker are emulating x86_64 and that is just a slow process.

We as a project are working towards ARM64 support, but a lot of work needs to happen so it won't be a fast process. We are presently at the place where you can build your own ARM64 images (takes about 20 mins) using the instructions here.

We also have an amazing community member @dashaun that has put together and continues to update images using this tool. He has a multi-arch image for Java native-image buildpacks here. You might consider giving these a try. They should speed things up considerably as you'll remove all the messy/slow emulation.

Hope that helps!

@dmikusa
Copy link
Contributor Author

dmikusa commented Dec 10, 2022

@pivotal-david-osullivan Do you think we can close this out? I think the original issue has been resolved. Unless you want to keep this open as a reminder to eventually go back and remove the workaround of adding USE_NATIVE_IMAGE_JAVA_PLATFORM_MODULE_SYSTEM. It seems like we don't need that now that we're at 22.3.

@abelsromero
Copy link

abelsromero commented Dec 12, 2022

@abelsromero The latest Bellsoft Liberica & Graalvm buildpacks are shipping 22.3, so you should not see the error mentioned on this ticket (both because of that, but because we are also automatically setting the previously mentioned env variable that works around this issue).

Indeed, thanks! I see we were hardcoding an old builder image. Latest builder still uses native 5.6 instead of 5.7 but so long is Graal 22.3 is fine

@DVader666
Copy link

DVader666 commented Dec 12, 2022

Currently on a M1 MacBook Pro with Monterrey 12.5.1 (company issued).

I have been trying a Spring Boot 3 sample project as a native image.

When building with GraalVM (GraalVM CE 22.3.0 build 17.0.5+8-jvmci-22.3-b08) via ./mvnw -Pnative clean native:compile everything works and the native executable is built in like 1.5 mins (it's a really small/simply Spring Cloud Function example). BUT when I try building with Paketo Buildpacks via ./mvnw -Pnative clean spring-boot:build-image the build process never finishes.

[INFO]  > Running creator
[INFO]     [creator]     ===> ANALYZING
[INFO]     [creator]     Previous image with name "docker.io/library/custom:0.0.1-SNAPSHOT" not found
[INFO]     [creator]     ===> DETECTING
[INFO]     [creator]     6 of 14 buildpacks participating
[INFO]     [creator]     paketo-buildpacks/ca-certificates   3.5.1
[INFO]     [creator]     paketo-buildpacks/bellsoft-liberica 9.10.1
[INFO]     [creator]     paketo-buildpacks/syft              1.23.0
[INFO]     [creator]     paketo-buildpacks/executable-jar    6.5.0
[INFO]     [creator]     paketo-buildpacks/spring-boot       5.20.0
[INFO]     [creator]     paketo-buildpacks/native-image      5.6.0
[INFO]     [creator]     ===> RESTORING
[INFO]     [creator]     ===> BUILDING
[INFO]     [creator]
[INFO]     [creator]     Paketo Buildpack for CA Certificates 3.5.1
[INFO]     [creator]       https://github.com/paketo-buildpacks/ca-certificates
[INFO]     [creator]       Launch Helper: Contributing to layer
[INFO]     [creator]         Creating /layers/paketo-buildpacks_ca-certificates/helper/exec.d/ca-certificates-helper
[INFO]     [creator]
[INFO]     [creator]     Paketo Buildpack for BellSoft Liberica 9.10.1
[INFO]     [creator]       https://github.com/paketo-buildpacks/bellsoft-liberica
[INFO]     [creator]       Build Configuration:
[INFO]     [creator]         $BP_JVM_JLINK_ARGS           --no-man-pages --no-header-files --strip-debug --compress=1  configure custom link arguments (--output must be omitted)
[INFO]     [creator]         $BP_JVM_JLINK_ENABLED        false                                                        enables running jlink tool to generate custom JRE
[INFO]     [creator]         $BP_JVM_TYPE                 JRE                                                          the JVM type - JDK or JRE
[INFO]     [creator]         $BP_JVM_VERSION              11                                                           the Java version
[INFO]     [creator]       Launch Configuration:
[INFO]     [creator]         $BPL_DEBUG_ENABLED           false                                                        enables Java remote debugging support
[INFO]     [creator]         $BPL_DEBUG_PORT              8000                                                         configure the remote debugging port
[INFO]     [creator]         $BPL_DEBUG_SUSPEND           false                                                        configure whether to suspend execution until a debugger has attached
[INFO]     [creator]         $BPL_HEAP_DUMP_PATH                                                                       write heap dumps on error to this path
[INFO]     [creator]         $BPL_JAVA_NMT_ENABLED        true                                                         enables Java Native Memory Tracking (NMT)
[INFO]     [creator]         $BPL_JAVA_NMT_LEVEL          summary                                                      configure level of NMT, summary or detail
[INFO]     [creator]         $BPL_JFR_ARGS                                                                             configure custom Java Flight Recording (JFR) arguments
[INFO]     [creator]         $BPL_JFR_ENABLED             false                                                        enables Java Flight Recording (JFR)
[INFO]     [creator]         $BPL_JMX_ENABLED             false                                                        enables Java Management Extensions (JMX)
[INFO]     [creator]         $BPL_JMX_PORT                5000                                                         configure the JMX port
[INFO]     [creator]         $BPL_JVM_HEAD_ROOM           0                                                            the headroom in memory calculation
[INFO]     [creator]         $BPL_JVM_LOADED_CLASS_COUNT  35% of classes                                               the number of loaded classes in memory calculation
[INFO]     [creator]         $BPL_JVM_THREAD_COUNT        250                                                          the number of threads in memory calculation
[INFO]     [creator]         $JAVA_TOOL_OPTIONS                                                                        the JVM launch flags
[INFO]     [creator]         Using Java version 17 extracted from MANIFEST.MF
[INFO]     [creator]       BellSoft Liberica NIK 17.0.5: Contributing to layer
[INFO]     [creator]         Downloading from https://download.bell-sw.com/vm/22.3.0/bellsoft-liberica-vm-core-openjdk17.0.5+8-22.3.0+2-linux-amd64.tar.gz
[INFO]     [creator]         Verifying checksum
[INFO]     [creator]         Expanding to /layers/paketo-buildpacks_bellsoft-liberica/native-image-svm
[INFO]     [creator]         Adding 124 container CA certificates to JVM truststore
[INFO]     [creator]         Writing env.build/JAVA_HOME.override
[INFO]     [creator]         Writing env.build/JDK_HOME.override
[INFO]     [creator]
[INFO]     [creator]     Paketo Buildpack for Syft 1.23.0
[INFO]     [creator]       https://github.com/paketo-buildpacks/syft
[INFO]     [creator]         Downloading from https://github.com/anchore/syft/releases/download/v0.62.1/syft_0.62.1_linux_amd64.tar.gz
[INFO]     [creator]         Verifying checksum
[INFO]     [creator]         Writing env.build/SYFT_CHECK_FOR_APP_UPDATE.default
[INFO]     [creator]
[INFO]     [creator]     Paketo Buildpack for Executable JAR 6.5.0
[INFO]     [creator]       https://github.com/paketo-buildpacks/executable-jar
[INFO]     [creator]       Class Path: Contributing to layer
[INFO]     [creator]         Writing env.build/CLASSPATH.delim
[INFO]     [creator]         Writing env.build/CLASSPATH.prepend
[INFO]     [creator]
[INFO]     [creator]     Paketo Buildpack for Spring Boot 5.20.0
[INFO]     [creator]       https://github.com/paketo-buildpacks/spring-boot
[INFO]     [creator]       Build Configuration:
[INFO]     [creator]         $BP_SPRING_CLOUD_BINDINGS_DISABLED   false  whether to contribute Spring Boot cloud bindings support
[INFO]     [creator]       Launch Configuration:
[INFO]     [creator]         $BPL_SPRING_CLOUD_BINDINGS_DISABLED  false  whether to auto-configure Spring Boot environment properties from bindings
[INFO]     [creator]         $BPL_SPRING_CLOUD_BINDINGS_ENABLED   true   Deprecated - whether to auto-configure Spring Boot environment properties from bindings
[INFO]     [creator]       Class Path: Contributing to layer
[INFO]     [creator]         native args file /workspace/META-INF/native-image/argfile
[INFO]     [creator]         Writing env.build/BP_NATIVE_IMAGE_BUILD_ARGUMENTS_FILE.default
[INFO]     [creator]         Writing env.build/CLASSPATH.append
[INFO]     [creator]         Writing env.build/CLASSPATH.delim
[INFO]     [creator]       Image labels:
[INFO]     [creator]         org.opencontainers.image.title
[INFO]     [creator]         org.opencontainers.image.version
[INFO]     [creator]         org.springframework.boot.version
[INFO]     [creator]     Warning: BOM table is deprecated in this buildpack api version, though it remains supported for backwards compatibility. Buildpack authors should write BOM information to <layer>.sbom.<ext>, launch.sbom.<ext>, or build.sbom.<ext>.
[INFO]     [creator]
[INFO]     [creator]     Paketo Buildpack for Native Image 5.6.0
[INFO]     [creator]       https://github.com/paketo-buildpacks/native-image
[INFO]     [creator]       Build Configuration:
[INFO]     [creator]         $BP_BINARY_COMPRESSION_METHOD                                                    Compression mechanism used to reduce binary size. Options: `none` (default), `upx` or `gzexe`
[INFO]     [creator]         $BP_NATIVE_IMAGE                       true                                      enable native image build
[INFO]     [creator]         $BP_NATIVE_IMAGE_BUILD_ARGUMENTS                                                 arguments to pass to the native-image command
[INFO]     [creator]         $BP_NATIVE_IMAGE_BUILD_ARGUMENTS_FILE  /workspace/META-INF/native-image/argfile  a file with arguments to pass to the native-image command
[INFO]     [creator]         $BP_NATIVE_IMAGE_BUILT_ARTIFACT                                                  the built application artifact explicitly, required if building from a JAR
[INFO]     [creator]       Native Image: Contributing to layer
[INFO]     [creator]         Executing native-image -H:+StaticExecutableWithDynamicLibC @/workspace/META-INF/native-image/argfile -H:Name=/layers/paketo-buildpacks_native-image/native-image/com.example.custom.CustomApplication -cp /workspace:/workspace/BOOT-INF/classes:/workspace/BOOT-INF/lib/spring-cloud-function-adapter-aws-4.0.0-SNAPSHOT.jar:/workspace/BOOT-INF/lib/spring-cloud-function-context-4.0.0-SNAPSHOT.jar:/workspace/BOOT-INF/lib/typetools-0.6.2.jar:/workspace/BOOT-INF/lib/spring-boot-autoconfigure-3.0.0.jar:/workspace/BOOT-INF/lib/spring-cloud-function-core-4.0.0-SNAPSHOT.jar:/workspace/BOOT-INF/lib/reactor-core-3.5.0.jar:/workspace/BOOT-INF/lib/reactive-streams-1.0.4.jar:/workspace/BOOT-INF/lib/spring-messaging-6.0.2.jar:/workspace/BOOT-INF/lib/spring-beans-6.0.2.jar:/workspace/BOOT-INF/lib/javax.annotation-api-1.3.2.jar:/workspace/BOOT-INF/lib/javax.activation-api-1.2.0.jar:/workspace/BOOT-INF/lib/jackson-databind-2.14.1.jar:/workspace/BOOT-INF/lib/spring-boot-3.0.0.jar:/workspace/BOOT-INF/lib/spring-context-6.0.2.jar:/workspace/BOOT-INF/lib/spring-aop-6.0.2.jar:/workspace/BOOT-INF/lib/spring-expression-6.0.2.jar:/workspace/BOOT-INF/lib/logback-classic-1.4.5.jar:/workspace/BOOT-INF/lib/logback-core-1.4.5.jar:/workspace/BOOT-INF/lib/log4j-to-slf4j-2.19.0.jar:/workspace/BOOT-INF/lib/log4j-api-2.19.0.jar:/workspace/BOOT-INF/lib/jul-to-slf4j-2.0.4.jar:/workspace/BOOT-INF/lib/jakarta.annotation-api-2.1.1.jar:/workspace/BOOT-INF/lib/snakeyaml-1.33.jar:/workspace/BOOT-INF/lib/jackson-datatype-joda-2.14.1.jar:/workspace/BOOT-INF/lib/jackson-annotations-2.14.1.jar:/workspace/BOOT-INF/lib/jackson-core-2.14.1.jar:/workspace/BOOT-INF/lib/spring-cloud-starter-function-webflux-4.0.0-SNAPSHOT.jar:/workspace/BOOT-INF/lib/spring-cloud-function-web-4.0.0-SNAPSHOT.jar:/workspace/BOOT-INF/lib/jackson-datatype-jdk8-2.14.1.jar:/workspace/BOOT-INF/lib/jackson-datatype-jsr310-2.14.1.jar:/workspace/BOOT-INF/lib/jackson-module-parameter-names-2.14.1.jar:/workspace/BOOT-INF/lib/reactor-netty-http-1.1.0.jar:/workspace/BOOT-INF/lib/netty-codec-http-4.1.85.Final.jar:/workspace/BOOT-INF/lib/netty-common-4.1.85.Final.jar:/workspace/BOOT-INF/lib/netty-buffer-4.1.85.Final.jar:/workspace/BOOT-INF/lib/netty-transport-4.1.85.Final.jar:/workspace/BOOT-INF/lib/netty-codec-4.1.85.Final.jar:/workspace/BOOT-INF/lib/netty-handler-4.1.85.Final.jar:/workspace/BOOT-INF/lib/netty-codec-http2-4.1.85.Final.jar:/workspace/BOOT-INF/lib/netty-resolver-dns-4.1.85.Final.jar:/workspace/BOOT-INF/lib/netty-resolver-4.1.85.Final.jar:/workspace/BOOT-INF/lib/netty-codec-dns-4.1.85.Final.jar:/workspace/BOOT-INF/lib/netty-resolver-dns-native-macos-4.1.85.Final-osx-x86_64.jar:/workspace/BOOT-INF/lib/netty-resolver-dns-classes-macos-4.1.85.Final.jar:/workspace/BOOT-INF/lib/netty-transport-native-epoll-4.1.85.Final-linux-x86_64.jar:/workspace/BOOT-INF/lib/netty-transport-native-unix-common-4.1.85.Final.jar:/workspace/BOOT-INF/lib/netty-transport-classes-epoll-4.1.85.Final.jar:/workspace/BOOT-INF/lib/reactor-netty-core-1.1.0.jar:/workspace/BOOT-INF/lib/netty-handler-proxy-4.1.85.Final.jar:/workspace/BOOT-INF/lib/netty-codec-socks-4.1.85.Final.jar:/workspace/BOOT-INF/lib/spring-web-6.0.2.jar:/workspace/BOOT-INF/lib/micrometer-observation-1.10.2.jar:/workspace/BOOT-INF/lib/micrometer-commons-1.10.2.jar:/workspace/BOOT-INF/lib/spring-webflux-6.0.2.jar:/workspace/BOOT-INF/lib/aws-lambda-java-events-3.11.0.jar:/workspace/BOOT-INF/lib/joda-time-2.6.jar:/workspace/BOOT-INF/lib/aws-lambda-java-core-1.2.2.jar:/workspace/BOOT-INF/lib/lombok-1.18.24.jar:/workspace/BOOT-INF/lib/slf4j-api-2.0.4.jar:/workspace/BOOT-INF/lib/spring-core-6.0.2.jar:/workspace/BOOT-INF/lib/spring-jcl-6.0.2.jar:/workspace/BOOT-INF/lib/spring-boot-jarmode-layertools-3.0.0.jar com.example.custom.CustomApplication

It gets stuck in there and stays in there until I kill it. I have increased memory and processors for Docker configuration (Docker Desktop v4.15.0 (93002)) and nothing changes.

Is this a different issue?

@dmikusa
Copy link
Contributor Author

dmikusa commented Dec 12, 2022

@DVader666 Please see this comment above -> #176 (comment).

You have an ARM64 machine and so when you build with buildpacks that is happening by default through an emulation layer (it would be faster on an AMD64 machine, or using ARM64 images). I have an ARM64 MBP as well and sometimes builds finish, but I often see what you're seeing where the native-image build just runs forever or eventually errors for some reason. The comment above has the latest info on that topic.

@dashaun
Copy link

dashaun commented Dec 13, 2022

@iuliana @DVader666 I have pushed out a new builder, just for you. It works on ARM64 & AMD64 and looks a lot like paketobuildpacks/builder:tiny on purpose.

@dashaun
Copy link

dashaun commented Dec 13, 2022

FYI

Spring Native is experimental and will not be supported going forward. All of the lessons learned with Spring Native were carried forward into Spring Framework 6 and Spring Boot 3.

Spring Boot 3 is now GA! Everything you love about #springnative is included, first class, in Spring Boot 3. The AOT processing / GraalVM native image features, require Java 17 and GraalVM native image 22.3.0 or above.

@cforce
Copy link

cforce commented Dec 15, 2022

Building an spring cloud function based on spring boot v3.0 as native executable using
OS: Linux
JDK: OpenJDK 17
Spring Boot: 3.0.0
Graal 22.30 (native-image buildpack)
Spring Cloud Function: 4.0.0-SNAPSHOT
Using todays (SNAPSHOT) graalvm-reachability-metadata

Step to reproduce:
"mvn -Pnative package" my spring cloud function app on my WSLES ubuntu shell

deploy zip file to aws lamda
execute lambda function
cloud-function-dynamodb-lambda: /lib64/libc.so.6: version `GLIBC_2.32' not found (required by ./cloud-function-dynamodb-lambda)
./cloud-function-dynamodb-lambda: /lib64/libc.so.6: version `GLIBC_2.34' not found (required by ./cloud-function-dynamodb-lambda)
./cloud-function-dynamodb-lambda: /lib64/libc.so.6: version `GLIBC_2.32' not found (required by ./cloud-function-dynamodb-lambda)
./cloud-function-dynamodb-lambda: /lib64/libc.so.6: version `GLIBC_2.34' not found (required by ./cloud-function-dynamodb-lambda)
START RequestId: 054fd135-79e2-4ec7-b080-11820822a134 Version: $LATEST
RequestId: 054fd135-79e2-4ec7-b080-11820822a134 Error: Runtime exited with error: exit status 1
Runtime.ExitError
END RequestId: 054fd135-79e2-4ec7-b080-11820822a134
REPORT RequestId: 054fd135-79e2-4ec7-b080-11820822a134	Duration: 75.74 ms	Billed Duration: 76 ms	Memory Size: 128 MB	Max Memory Used: 4 MB	
XRAY TraceId: 1-639994f6-6fc8489d57c0cd106bdbaee8	SegmentId: 11040f061038b2f9	Sampled: true	

IT seems like the existing buildpack used is not providing the same? GLIBC version which is offered used by the aws lambda provided runtime.
Is there any buildback which provides a aws lambda compatible environment to build a graal native image which can be executed published as part of zipped package requesting for dynamic shared lib objects being available on aws provided runtime?

@dmikusa
Copy link
Contributor Author

dmikusa commented Dec 15, 2022

@cforce That's a different issue. Please create a new issue for it.

@cforce
Copy link

cforce commented Dec 15, 2022

@dmikusa Ok - shall i do it here or at https://github.com/paketo-buildpacks/spring-boot/issues ?

continued here : #217

@dmikusa
Copy link
Contributor Author

dmikusa commented Dec 15, 2022

Here is fine. Go up to the top of this page & hit the "New Issue" button.

@sdeleuze
Copy link

@pivotal-david-osullivan @dmikusa The original issue is expected to be solved with GraalVM 22.3, so after local testing it works as expected, customization of USE_NATIVE_IMAGE_JAVA_PLATFORM_MODULE_SYSTEM should likely be removed and this issue closed since Spring Boot 3 only supports 22.3 and I think this issue was specific to Boot.

@dmikusa
Copy link
Contributor Author

dmikusa commented Jul 7, 2023

I created #273 to track removing since this comment thread is getting long. Closing this one out.

@dmikusa dmikusa closed this as completed Jul 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug A general bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants