Building Native
urmichm opened this issue · 11 comments
Good morning,
I am trying to build a native for a spring-boot app, but I am facing an issue building native. Once the docker runs I executed mvn clean package -Pnative
but it was frozen on the step:
[INFO] Executing: /usr/lib/graalvm/bin/native-image -cp /root/.m2/repository/org/springframework/boot/spring-boot-starter/2.6.6/spring-boot-starter-2.6.6.jar:
/root/.m2/repository/org/springframework/boot/spring-boot/2.6.6/spring-boot-2.6.6.jar:
/root/.m2/repository/org/springframework/spring-context/5.3.18/spring-context-5.3.18.jar:
/root/.m2/repository/org/springframework/spring-aop/5.3.18/spring-aop-5.3.18.jar:
/root/.m2/repository/org/springframework/spring-expression/5.3.18/spring-expression-5.3.18.jar:/root/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/2.6.6/spring-boot-autoconfigure-2.6.6.jar:/root/.m2/repository/org/springframework/boot/spring-boot-starter-logging/2.6.6/spring-boot-starter-logging-2.6.6.jar:/root/.m2/repository/ch/qos/logback/logback-classic/1.2.11/logback-classic-1.2.11.jar:/root/.m2/repository/ch/qos/logback/logback-core/1.2.11/logback-core-1.2.11.jar:/root/.m2/repository/org/apache/logging/log4j/log4j-to-slf4j/2.17.2/log4j-to-slf4j-2.17.2.jar:/root/.m2/repository/org/apache/logging/log4j/log4j-api/2.17.2/log4j-api-2.17.2.jar:/root/......
It has been frozen for 8 hours. I sent a terminate signal a got the following:
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 08:03 h
[INFO] Finished at: 2022-07-12T05:18:17Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.graalvm.buildtools:native-maven-plugin:0.9.9:build (build-native) on project springboot-lambda-function: Execution of /usr/lib/graalvm/bin/native-image -cp /root/.m2/repository/org/springframework/boot/spring-boot-starter/2.6.6/spring-boot-starter-2.6.6.jar:
/root/.m2/repository/org/springframework/boot/spring-boot/2.6.6/spring-boot-2.6.6.jar:
/root/.m2/repository/org/springframework/spring-context/5.3.18/spring-context-5.3.18.jar:
/root/.m2/repository/org/springframework/spring-aop/5.3.18/spring-aop-5.3.18.jar:
/root/.m2/repository/org/springframework/spring-expression/5.3.18/spring-expression-5.3.18.jar:/root/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/2.6.6/spring-boot-autoconfigure-2.6.6.jar:/root/.m2/repository/org/springframework/boot/spring-boot-start......
I am using mac Monterey. Chip Apple M1. Memory 8GB. Could you please have a look and advise the following steps?
After increasing the resources for Docker, i moved few steps further but still frozen on the following:
========================================================================================================================
GraalVM Native Image: Generating 'springboot-lambda-function'...
========================================================================================================================
[1/7] Initializing... (47.9s @ 0.19GB)
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.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.
Version info: 'GraalVM 22.0.0.2 Java 11 CE'
[2/7] Performing analysis... [
I have found this container.
arm64-al2-graalvm:17-22.0.0.2
docker run --mount type=bind,source=$(pwd),destination=/project -it --entrypoint /bin/bash marksailes/arm64-al2-graalvm:17-22.0.0.2
Can you confirm if this one is legit? I managed to build with this container, but it did not launch after deployment with log:
/var/task/bootstrap: line 5: ./springboot-lambda-function: cannot execute binary file
since I cannot execute the binary probably, arm64-al2-graalvm:17-22.0.0.2 is not simply an adaptation of the container for the M1 chip. However, the building is still frozen when I run it on al2-graalvm
could you please help me with this issue?
@urmichm I don't think M1 chip support is available yet. Let me ask around.
@dmahapatro thank you a lot.
Looking forward to hearing from you
Hi @urmichm,
marksailes/arm64-al2-graalvm:17-22.0.0.2 is an image I created. I would recommend taking a copy for yourself for any meaningful use (prod). This is what I use when using GraalVM native-image.
Have you also changed the Lambda function architecture when you've create a ARM binary?
Hi @msailes
Wonderful, I will also use marksailes/arm64-al2-graalvm:17-22.0.0.2. Thank you.
However, I have not changed the Lambda function architecture, could you help me with it? I was getting the error:
/var/task/bootstrap: line 5: ./springboot-lambda-function: cannot execute binary file
What are there changes needed to be done?
Since you're now making a ARM binary, you need to run it on an ARM compatible host.
You'll need to update the SAM template to reflect that.
@msailes Thank you a lot, I will try it.
Would you mind answering one more simple question?
I am planning to build my Spring app with Controllers and MapRequests annotations rather than Function<T,R> interface.
Can I build my app based on this project?
Hello @msailes @dmahapatro,
Your suggestions helped me a lot. I have updated my repo accordingly, I believe this could help others as well.
If you are interested, I have opened a Pull Request with an updated README and an additional template YAML file.
Thank you once again for your help!
@urmichm Excuse me for a late reply. Thank you for the PR. The PR has been merged.