** I have updated below **
Here is my info.
| Java version | 17.0.7+8-LTS
|
| Vendor version | Oracle GraalVM 17.0.7+8.1
|
Relevant Pom changes for native image:
<dependency>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>graalvm-reachability-metadata</artifactId>
<version>${native.maven.plugin.version}</version>
<classifier>repository</classifier>
<type>zip</type>
</dependency>
</dependencies>
<profiles>
<profile>
<id>native</id>
<build>
<plugins>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>${native.maven.plugin.version}</version>
<extensions>true</extensions>
<executions>
<execution>
<id>build-native</id>
<goals>
<goal>compile-no-fork</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
<configuration>
<metadataRepository>
<enabled>true</enabled>
</metadataRepository>
<skipNativeTests>true</skipNativeTests>
<imageName>${imageName}</imageName>
<fallback>false</fallback>
<verbose>true</verbose>
<agent>
<defaultMode>Standard</defaultMode>
<enabled>true</enabled>
<modes>
<direct>config-output-dir=${project.build.directory}/native/agent-output</direct>
</modes>
<trackReflectionMetadata>true</trackReflectionMetadata>
</agent>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>java-agent</id>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>java</executable>
<workingDirectory>${project.build.directory}</workingDirectory>
<arguments>
<argument>-classpath</argument>
<classpath/>
<argument>${mainClass}</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>java-agent</id>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>java</executable>
<workingDirectory>${project.build.directory}</workingDirectory>
<arguments>
<argument>-classpath</argument>
<classpath/>
<argument>${mainClass}</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>java</id>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>${mainClass}</mainClass>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<configuration>
<skipNativeTests>true</skipNativeTests>
</configuration>
</plugin>
I would run mvn -Pnative -DskipTests native:compile This produces these folders in target with the json files, but they all these packages such as ch.qos.logbacj, com.google.protobuf, io.netty, etc which i don't direclty use in my app: classes/META-INF/native-image, graalvm-reachability-metadata, spring-aot. I tried taking the spring-aot META-INF json files and place it into the app's classpath. I would run again and the logs would indicate it transfers the classpath folders into target classes folder and applys all the json files in the target/classes/META-INF
At the end, i get a lot of warning on all these obscure classes and this error at end:
C compiler: cl.exe (microsoft, x64, 19.36.32537)
Garbage collector: Serial GC (max heap size: 80% of RAM)
6 user-specific feature(s)
- com.google.api.gax.grpc.nativeimage.GrpcNettyFeature
- com.google.api.gax.grpc.nativeimage.ProtobufMessageFeature
- com.google.api.gax.nativeimage.GoogleJsonClientFeature
- com.google.api.gax.nativeimage.OpenCensusFeature
- com.oracle.svm.thirdparty.gson.GsonFeature
- org.springframework.aot.nativex.feature.PreComputeFieldFeature
Warning: Unknown attribute(s) [//note] in resource and resource bundle descriptor object
Aug 17, 2023 11:03:20 AM com.google.api.gax.nativeimage.NativeImageUtils registerClassForReflection
WARNING: Failed to find io.grpc.netty.shaded.io.netty.channel.ProtocolNegotiators on the classpath for reflection.
WARNING: Resource scanning is taking a long time. This can be caused by class-path or module-path entries that point to large directory structures. Please make sure class-/module-path entries are easily accessible to native-image
Total scanned entries: 37590, current entry: file:///C:/graalvm-jdk-17.0.7+8.1/lib/svm/builder/svm.jar
Total scanned entries: 49314, current entry: file:///C:/Users/myself/.m2/repository/io/netty/netty-handler/4.1.94.Final/netty-handler-4.1.94.Final.jar
Total scanned entries: 62667, current entry: file:///C:/Users/myself/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.13.4.1/jackson-databind-2.13.4.1.jar
Total scanned entries: 74685, current entry: file:///C:/Users/myself/.m2/repository/org/springframework/spring-aop/6.0.10/spring-aop-6.0.10.jar
Total scanned entries: 88132, current entry: file:///C:/Users/myself/.m2/repository/org/springframework/data/spring-data-commons/3.0.7/spring-data-commons-3.0.7.jar
Total scanned entries: 101563, current entry: file:///C:/Users/myself/.m2/repository/io/opencensus/opencensus-api/0.31.1/opencensus-api-0.31.1.jar
Stack Trace
java.lang.NullPointerException: Cannot invoke "java.util.Set.iterator()" because "triggers" is null
That is a section of some of the errors. There are a lot of these warning errors. I do have an xx.json files generated in native/agent-output/main. How can I resolve these and get the image generated?
** UPDATE ** August 21st 2023 **** Based on looking into the error, I found that when i comment out the google dependency, the native build completes successfully but my app doesn't run.
I commented out this dependency:
com.google.cloud spring-cloud-gcp-dependencies and gcp secret manager dependency.
Now i get this error: Segmentation fault: 11 (using mac). I am currently trying to use a older version of xCode 12.5.1