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

Error Encountered When Building Native Image with Spring Boot Maven Plugin #756

Closed
kcsurapaneni opened this issue Jul 23, 2024 · 9 comments

Comments

@kcsurapaneni
Copy link

I encountered an error while attempting to run the spring-boot-native-image-maven sample project using the Spring Boot Maven Plugin command (./mvnw -Dmaven.test.skip=true spring-boot:build-image -Pnative).

Here are the details of the error:

[INFO]     [creator]       Native Image: Contributing to layer
[INFO]     [creator]         Executing native-image --no-fallback -H:+StaticExecutableWithDynamicLibC @/workspace/META-INF/native-image/argfile -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-3.1.0.jar:/workspace/BOOT-INF/lib/spring-context-6.0.9.jar:/workspace/BOOT-INF/lib/spring-aop-6.0.9.jar:/workspace/BOOT-INF/lib/spring-expression-6.0.9.jar:/workspace/BOOT-INF/lib/spring-boot-autoconfigure-3.1.0.jar:/workspace/BOOT-INF/lib/logback-classic-1.4.7.jar:/workspace/BOOT-INF/lib/logback-core-1.4.7.jar:/workspace/BOOT-INF/lib/log4j-to-slf4j-2.20.0.jar:/workspace/BOOT-INF/lib/log4j-api-2.20.0.jar:/workspace/BOOT-INF/lib/jul-to-slf4j-2.0.7.jar:/workspace/BOOT-INF/lib/jakarta.annotation-api-2.1.1.jar:/workspace/BOOT-INF/lib/snakeyaml-1.33.jar:/workspace/BOOT-INF/lib/spring-boot-actuator-autoconfigure-3.1.0.jar:/workspace/BOOT-INF/lib/spring-boot-actuator-3.1.0.jar:/workspace/BOOT-INF/lib/jackson-databind-2.15.0.jar:/workspace/BOOT-INF/lib/jackson-annotations-2.15.0.jar:/workspace/BOOT-INF/lib/jackson-core-2.15.0.jar:/workspace/BOOT-INF/lib/jackson-datatype-jsr310-2.15.0.jar:/workspace/BOOT-INF/lib/micrometer-observation-1.11.0.jar:/workspace/BOOT-INF/lib/micrometer-commons-1.11.0.jar:/workspace/BOOT-INF/lib/micrometer-core-1.11.0.jar:/workspace/BOOT-INF/lib/HdrHistogram-2.1.12.jar:/workspace/BOOT-INF/lib/LatencyUtils-2.0.3.jar:/workspace/BOOT-INF/lib/jackson-datatype-jdk8-2.15.0.jar:/workspace/BOOT-INF/lib/jackson-module-parameter-names-2.15.0.jar:/workspace/BOOT-INF/lib/reactor-netty-http-1.1.7.jar:/workspace/BOOT-INF/lib/netty-codec-http-4.1.92.Final.jar:/workspace/BOOT-INF/lib/netty-common-4.1.92.Final.jar:/workspace/BOOT-INF/lib/netty-buffer-4.1.92.Final.jar:/workspace/BOOT-INF/lib/netty-transport-4.1.92.Final.jar:/workspace/BOOT-INF/lib/netty-codec-4.1.92.Final.jar:/workspace/BOOT-INF/lib/netty-handler-4.1.92.Final.jar:/workspace/BOOT-INF/lib/netty-codec-http2-4.1.92.Final.jar:/workspace/BOOT-INF/lib/netty-resolver-dns-4.1.92.Final.jar:/workspace/BOOT-INF/lib/netty-resolver-4.1.92.Final.jar:/workspace/BOOT-INF/lib/netty-codec-dns-4.1.92.Final.jar:/workspace/BOOT-INF/lib/netty-resolver-dns-native-macos-4.1.92.Final-osx-x86_64.jar:/workspace/BOOT-INF/lib/netty-resolver-dns-classes-macos-4.1.92.Final.jar:/workspace/BOOT-INF/lib/netty-transport-native-epoll-4.1.92.Final-linux-x86_64.jar:/workspace/BOOT-INF/lib/netty-transport-native-unix-common-4.1.92.Final.jar:/workspace/BOOT-INF/lib/netty-transport-classes-epoll-4.1.92.Final.jar:/workspace/BOOT-INF/lib/reactor-netty-core-1.1.7.jar:/workspace/BOOT-INF/lib/netty-handler-proxy-4.1.92.Final.jar:/workspace/BOOT-INF/lib/netty-codec-socks-4.1.92.Final.jar:/workspace/BOOT-INF/lib/spring-web-6.0.9.jar:/workspace/BOOT-INF/lib/spring-beans-6.0.9.jar:/workspace/BOOT-INF/lib/spring-webflux-6.0.9.jar:/workspace/BOOT-INF/lib/slf4j-api-2.0.7.jar:/workspace/BOOT-INF/lib/spring-core-6.0.9.jar:/workspace/BOOT-INF/lib/spring-jcl-6.0.9.jar:/workspace/BOOT-INF/lib/reactor-core-3.5.6.jar:/workspace/BOOT-INF/lib/reactive-streams-1.0.4.jar:/workspace/BOOT-INF/lib/spring-boot-jarmode-layertools-3.1.0.jar io.paketo.demo.DemoApplication
[INFO]     [creator]     Warning: The USE_NATIVE_IMAGE_JAVA_PLATFORM_MODULE_SYSTEM environment variable is deprecated and might be removed in a future release. Please refer to the GraalVM release notes.
[INFO]     [creator]     #
[INFO]     [creator]     # A fatal error has been detected by the Java Runtime Environment:
[INFO]     [creator]     #
[INFO]     [creator]     #  SIGSEGV (0xb) at pc=0x00007ffffe012321, pid=225, tid=253
[INFO]     [creator]     #
[INFO]     [creator]     # JRE version: OpenJDK Runtime Environment Liberica-NIK-23.0.0-1 (17.0.7+7) (build 17.0.7+7-LTS)
[INFO]     [creator]     # Java VM: OpenJDK 64-Bit Server VM Liberica-NIK-23.0.0-1 (17.0.7+7-LTS, mixed mode, tiered, jvmci, compressed oops, compressed class ptrs, parallel gc, linux-amd64)
[INFO]     [creator]     # Problematic frame:
[INFO]     [creator]     # V  [libjvm.so+0xcc5321]  oopDesc* PSPromotionManager::copy_unmarked_to_survivor_space<false>(oopDesc*, markWord)+0x31
[INFO]     [creator]     #
[INFO]     [creator]     # No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
[INFO]     [creator]     #
[INFO]     [creator]     # An error report file with more information is saved as:
[INFO]     [creator]     # /layers/paketo-buildpacks_native-image/native-image/hs_err_pid225.log
[INFO]     [creator]     #
[INFO]     [creator]     # If you would like to submit a bug report, please visit:
[INFO]     [creator]     #   https://bell-sw.com/support
[INFO]     [creator]     #
[INFO]     [creator]     Error: Image build request for 'io.paketo.demo.DemoApplication' (pid: 225, path: /layers/paketo-buildpacks_native-image/native-image) failed with exit status 134
[INFO]     [creator]     unable to invoke layer creator
[INFO]     [creator]     unable to contribute native-image layer
[INFO]     [creator]     error running build
[INFO]     [creator]     exit status 134
[INFO]     [creator]     ERROR: failed to build: exit status 1

Here is the java -version output

openjdk version "17.0.6" 2023-01-17 LTS
OpenJDK Runtime Environment Corretto-17.0.6.10.1 (build 17.0.6+10-LTS)
OpenJDK 64-Bit Server VM Corretto-17.0.6.10.1 (build 17.0.6+10-LTS, mixed mode, sharing)

Docker Resources Allocation

docker resources config

If you have any suggestions or need additional information to help resolve this issue, I would greatly appreciate it.

@kcsurapaneni
Copy link
Author

Apologies, it seems official arm64 support isn't available at this time. Closing this issue.

Note: For those interested in running on arm64, please refer to this project: https://github.com/dashaun/paketo-arm64

@dmikusa
Copy link
Contributor

dmikusa commented Jul 23, 2024

Apologies, it seems official arm64 support isn't available at this time. Closing this issue.

This is not true. ARM64 support has been available since paketo-buildpacks/java-native-image version 9.2.0, see https://github.com/paketo-buildpacks/java-native-image/releases/tag/v9.2.0.

@dmikusa
Copy link
Contributor

dmikusa commented Jul 23, 2024

I noticed some similar crashes when I build on my MBP M-series laptop but on an AMD64 builder. This is probably because of the emulation layer. Rosetta does this sometimes.

When I build using ARM64, no problems. So my guess is that your build didn't actually run on ARM64, which wouldn't normally fail, but occasionally has problems with Rosetta. You can turn off Rosetta in Docker -> Settings, but it'll be super slow (still slow with Rosetta, but not as slow).

You can see what I changed in this PR -> #757

or wait till it's merged and retry.

@kcsurapaneni
Copy link
Author

Hi @dmikusa, thank you for the information.

I noticed some similar crashes when I build on my MBP M-series laptop but on an AMD64 builder.

You're correct. Even after aligning the build configuration (pom.xml) with your pull request, I encountered the same error. Additionally, all dependencies are using the latest versions:

[INFO]     [creator]     paketo-buildpacks/ca-certificates   3.8.2
[INFO]     [creator]     paketo-buildpacks/bellsoft-liberica 10.8.1
[INFO]     [creator]     paketo-buildpacks/syft              1.47.1
[INFO]     [creator]     paketo-buildpacks/executable-jar    6.10.1
[INFO]     [creator]     paketo-buildpacks/spring-boot       5.30.1
[INFO]     [creator]     paketo-buildpacks/native-image      5.14.1

You can turn off Rosetta in Docker -> Settings, but it'll be super slow (still slow with Rosetta, but not as slow)

By following your suggestion, it did resolve the issue. However, as you said, the process remains excessively slow. Initially, using the emulator took 04:19 min, but after disabling it, the build time extended to 15:32 min, though the build was successful.

Thanks again for clarifying and providing all the necessary information.

@dmikusa
Copy link
Contributor

dmikusa commented Jul 25, 2024

Even after aligning the build configuration (pom.xml) with your pull request, I encountered the same error.

That doesn't sound right. If you update and pull in the changes from that PR, when you run ./mvnw -Dmaven.test.skip=true spring-boot:build-image -Pnative it should do a native image build on arm64 images. Watch the output of Bellsoft Liberica and you should see it install the aarch64 version of Java.

If that's not working, then please include the full build output so I can see what's happening.

@kcsurapaneni
Copy link
Author

That doesn't sound right.

The issue was due to docker using of the Rosetta layer. Following your suggestion to turn it off, everything is now functioning correctly. Here's the information you provided.

I noticed some similar crashes when I build on my MBP M-series laptop but on an AMD64 builder. This is probably because of the emulation layer. Rosetta does this sometimes.

@dmikusa
Copy link
Contributor

dmikusa commented Jul 26, 2024

@kcsurapaneni Right, but if you pulled the latest sample code and are running it on an M-series Mac, it should pull ARM64 images and there shouldn't be any emulation, Rosetta or crashes.

The Paketo Java buildpacks have support for ARM64. You can do native builds without emulation or Rosetta on an M-Series MBP. The trick is that you need to use a specific builder, paketobuildpacks/builder-jammy-buildpackless-tiny. The change I made in the samples repo with the referenced PR should configure that builder for you automatically, so running ./mvnw -Dmaven.test.skip=true spring-boot:build-image -Pnative should do a native ARM64 build.

That's the expectation anyway. If you're not seeing that, I'm curious to know more so we can make this a good experience.

@kcsurapaneni
Copy link
Author

kcsurapaneni commented Jul 26, 2024

@dmikusa, It looks like I made an error when copying the configuration from your PR earlier. I’ve just pulled the code again since the PR has been merged, and everything appears to be correct now. I'm not sure what I missed before, but I believe our pom.xml files were in sync. The only difference I can think of might be the Maven wrapper.

If you still want to see what is the error I was getting earlier, even after configuration update, please find the log here. I've created a repository for the log file since it's too large to include here.

@dmikusa
Copy link
Contributor

dmikusa commented Jul 26, 2024

Ok, no worries. Glad it's working for you now! That's what's important.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants