0

I'm trying to migrate a java spring boot application to use spring boot native implementation and I'm facing some problems to realize it. Many of the problems that I've faced I solved just googling, but this one with aws credentials provider I couldn't find any help.

I generate the executable file running: mvn -Pnative -DskipTests clean install. I'm using maven 3.8.6 and sdkman with graalvm 22.2.r17-grl.

The problem occurs when I trying to execute the generated file. This is the error I'm facing: Native reflection configuration for com.amazonaws.auth.AWSStaticCredentialsProvider.<init>(com.amazonaws.auth.AWSCredentials) is missing

This is the main parts of my pom.xml:

...<spring-native.version>0.12.1</spring-native.version>
    <native-maven-plugin.version>0.9.13</native-maven-plugin.version>
<springcloud-starter-aws-messaging.version>2.2.6.RELEASE</springcloud-starter-aws-messaging.version>...

...<dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-aws-messaging</artifactId>
        <version>${springcloud-starter-aws-messaging.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.experimental</groupId>
        <artifactId>spring-native</artifactId>
        <version>${spring-native.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.experimental</groupId>
        <artifactId>spring-aot</artifactId>
        <version>${spring-native.version}</version>
    </dependency>...

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <excludes>
                    <exclude>
                        <groupId>org.projectlombok</groupId>
                        <artifactId>lombok</artifactId>
                    </exclude>
                </excludes>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.springframework.experimental</groupId>
            <artifactId>spring-aot-maven-plugin</artifactId>
            <version>${spring-native.version}</version>
            <executions>
                <execution>
                    <id>test-generate</id>
                    <goals>
                        <goal>test-generate</goal>
                    </goals>
                </execution>
                <execution>
                    <id>generate</id>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

<profiles>
    <profile>
        <id>native</id>
        <dependencies>
            <dependency>
                <groupId>org.junit.platform</groupId>
                <artifactId>junit-platform-launcher</artifactId>
                <scope>test</scope>
            </dependency>
        </dependencies>
        <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>build</goal>
                            </goals>
                            <phase>package</phase>
                        </execution>
                    </executions>
                    <configuration>
                        <debug>true</debug>
                        <verbose>true</verbose>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <configuration>
                        <excludes>
                            <exclude>
                                <groupId>org.projectlombok</groupId>
                                <artifactId>lombok</artifactId>
                            </exclude>
                        </excludes>
                        <classifier>exec</classifier>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

And this is my java QueueMessagingTemplate configuration:

@Bean
public QueueMessagingTemplate queueMessagingTemplate(AmazonSQSAsync amazonSQSAsync) {
    return new QueueMessagingTemplate(amazonSQSAsync);
}

Does anybody have an idea about how to solve it?

  • I don't think it's your code shown here that is the problem because there's no reflection involved (during `new AWSStaticCredentialsProvider(..)`). The spring cloud internal code that configures an `AWSStaticCredentialsProvider` once you specify `cloud.aws.credentials.access-key` in config on the other hand would probably use reflection. I don't think you have to set a credentials provider manually here but that would probably not solve the problem either – zapl Oct 17 '22 at 22:05
  • The entire java config looks like it could actually be dropped because the framework will already configure those things. The error you get is likely caused by missing native support for `spring-cloud-starter-aws-messaging` - you would have to add missing reflection configuration via those methods mentioned https://docs.spring.io/spring-native/docs/current/reference/htmlsingle/#_missing_configuration but that could be a lot of work and there is also https://github.com/oracle/graal/issues/1441 and plenty of other issue with aws-java-sdk v1 which won't change until 3.x spring cloud aws – zapl Oct 17 '22 at 23:22
  • Hey @zapl, you were completely right, all my config code wasn't necessary, and as you mentioned before, the error ocurred before this configuration, it were happening when the spring context were starting up. I removed all the unnecessary code (edited my post here too), but even though the same error still happen. – Rodrigo Fournier Oct 18 '22 at 04:25

0 Answers0