I am attempting to build a native image on MacOS for an AWS Lambda function. The application compiles and runs just fine in the IDE, but I am hitting the following issue(s) when I try the native image build:
mvn clean install -Dnative -Dquarkus.native.container-build=true
mvn clean install -Pnative -Dquarkus.native.container-build=true
With following in my pom.xml file, the build fails
<dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-amazon-lambda</artifactId> </dependency>
Error: Unsupported features in 4 methods Detailed message: Error: Detected an instance of Random/SplittableRandom class in the image heap. Instances created during image generation have cached seed values and don't behave as expected. To see how this object got instantiated use --trace-object-instantiation=java.util.Random. The object was probably created by a class initializer and is reachable from a static field. You can request class initialization at image runtime by using the option --initialize-at-run-time=. Or you can write your own initialization methods and call them explicitly from your main entry point. Trace: Object was reached by reading field com.amazonaws.retry.PredefinedBackoffStrategies$EqualJitterBackoffStrategy.random of constant com.amazonaws.retry.PredefinedBackoffStrategies$EqualJitterBackoffStrategy@a7c6c06 reached by reading field com.amazonaws.retry.PredefinedBackoffStrategies$SDKDefaultBackoffStrategy.equalJitterBackoffStrategy of constant com.amazonaws.retry.PredefinedBackoffStrategies$SDKDefaultBackoffStrategy@6f61d2d9 reached by scanning method com.amazonaws.retry.PredefinedRetryPolicies.getDefaultBackoffStrategy(PredefinedRetryPolicies.java:110)
If I change the pom file to the following
<dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-amazon-lambda-archetype</artifactId> <version>2.4.2.Final</version> </dependency>
the build succeeds without error, but the function.zip for example is not created in the /target directory.
[Content of the /target directory]
- com_abc_demo_xyz-1.0-SNAPSHOT-native-image-source-jar
- com_abc_demo_xyz-1.0-SNAPSHOT-runner
- com_abc_demo_xyz-1.0-SNAPSHOT.jar
- failsafe-reports
- generated-sources
- maven-archiver
- maven-status
- quarkus-app
- quarkus-artifact.properties
[Test Environment]
- Java Version 11.0.6
- Docker Desktop 4.1.1
- macOS Monterey
- Maven 3.8.3
- GraalVM: graalvm-ce-java11-21.3.0
- JAVA_PATH=/Library/Java/JavaVirtualMachines/amazon-corretto-11.jdk/Contents/Home
- GRAALVM_HOME=/Library/Java/JavaVirtualMachines/graalvm-ce-java11-21.3.0/Contents/Home
Even with the debug feature enabled it does not make sense to me how to resolve this matter.
Les