0

I have an app built with Spring Boot 3.0.0-M5, Spring Cloud 2022.0.0-M4, Java 17. Its GitHub repo is https://github.com/wenqiglantz/springboot3-webclient/tree/metadata. I am trying to achieve the following:

  1. Enable metadataRepository configuration in native-maven-plugin in my app to assist in my native image build as this plugin automatically searches for GraalVM reachability metadata repo.
  2. Need to create a custom runtime (in a zip format) using maven-assembly-plugin as I need to deploy my app to AWS Lambda since Lambda doesn't yet support Java 17 runtime.

I was able to generate the custom runtime in a zip file with maven-assembly-plugin and a few config files in my source code and deploy to Lambda (my github actions workflow run https://github.com/wenqiglantz/springboot3-webclient/actions/runs/3146602388/jobs/5115233455). However, after adding native-maven-plugin to enable metadataRepository, my custom runtime build broke, it no longer generates the zip file (github actions workflow run https://github.com/wenqiglantz/springboot3-webclient/actions/runs/3151692666/jobs/5125968700). Also see attached the comparison screenshot. The maven command I use in my workflow is mvn -ntp clean package -Pnative -e -X. In my root pom. Unfortunately I have not been able to find any good documentation on either GraalVM side or Spring Boot side on how to configure such plugins to achieve what I want. I have the plugins configured as the following, let me know what's the best way to handle configuring both maven-assembly-plugin and native-maven-plugin so I can accomplish my two goals listed above.

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <executions>
                <execution>
                    <id>native-zip</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                    <inherited>false</inherited>
                </execution>
            </executions>
            <configuration>
                <descriptors>
                    <descriptor>src/assembly/native.xml</descriptor>
                </descriptors>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.graalvm.buildtools</groupId>
            <artifactId>native-maven-plugin</artifactId>
            <version>0.9.14</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>
            </configuration>
        </plugin>
    </plugins>
</build>

enter image description here

Brian Clozel
  • 56,583
  • 15
  • 167
  • 176
  • It looks like the assembly plugin [is still running](https://github.com/wenqiglantz/springboot3-webclient/actions/runs/3151692666/jobs/5125968700#step:8:7749), but much earlier in script. Perhaps that's causing the issue as the native executable isn't available at that point. This answer might help with changing the order https://stackoverflow.com/a/47475213/1526192 – Phil Webb Sep 30 '22 at 20:46
  • Thanks @Phil Webb! Your suggestion worked! I moved maven-assembly-plugin to be the last plugin in my pom, and surely the latest build does contain the zip file! Thanks so much! – Wenqi Glantz Oct 01 '22 at 03:47
  • @PhilWebb, even though the custom runtime now generates the zip file, I ran into the following error at runtime: `UnsatisfiedDependencyException: Error creating bean with name 'jacksonObjectMapper': Unsatisfied dependency expressed through method 'jacksonObjectMapper' parameter 0: Error creating bean with name 'jsonMixinModule': I/O failure during classpath scanning`, which was caused by `NoSuchFileException: /opt/hostedtoolcache/graalvm-ce-java17-linux/22.2.0/x64/graalvm-ce-java17-22.2.0/lib/svm/builder/pointsto.jar`. Let me know if you can help resolve this error. Thanks! – Wenqi Glantz Oct 01 '22 at 04:03
  • That's a completely different error so we can't really discuss it here. I'd report the error to the Graal project like I suggested last time. Please attach the full stacktrace when doing so. – Stephane Nicoll Oct 01 '22 at 10:44
  • Thanks @StephaneNicoll. I just submitted a new issue in GraalVM repo: https://github.com/oracle/graal/issues/5126. I appreciate all your and Phil's help and guidance. – Wenqi Glantz Oct 01 '22 at 16:01

0 Answers0