错误:使用micronaut-bom1.2.10,graal19.2.1和aws-sdk2.10.56构建应用程序时出现org.apache.commons.logging.LogFactoryjava.lang.NoClassDefFoundError

时间:2020-02-06 12:49:31

标签: aws-sdk micronaut graalvm-native-image

使用micronaut bom 1.2.10版本以及software.amazon.awssdk:lambda:2.10.56和software.amazon.awssdk:s3:2.10.56依赖项创建了一个应用程序,这些依赖项具有从s3存储和使用graal 19.2.1创建本地图像。 本机映像已成功创建,但是当我尝试访问端点时,由于以下异常而失败:

failed: org.apache.commons.logging.LogFactoryjava.lang.NoClassDefFoundError: org.apache.commons.logging.LogFactory

和一系列例外,特别是在创建S3客户端时。 异常在以下几点也失败了:

failed: Could not initialize class software.amazon.awssdk.http.apache.internal.conn.SdkTlsSocketFactoryjava.lang.NoClassDefFoundError: Could not initialize class software.amazon.awssdk.http.apache.internal.conn.SdkTlsSocketFactory

S3Client的代码:

S3Client s3Client = S3Client.builder().region(getRegion()).build();

build-native-image.sh

${GRAALVM_HOME}/bin/native-image --no-server -cp example-function-*-all.jar
-H:IncludeResources="git.properties"
-H:IncludeResources="logback.xml"
-H:IncludeResources="application.properties" \

1 个答案:

答案 0 :(得分:1)

因此,通过在build.gradle中添加以下配置来解决此问题:

allprojects {
    configurations {
        all {
            exclude(group = "commons-logging")
        }
    }
}

并在添加的依赖项中: compile group: 'org.slf4j', name: 'jcl-over-slf4j', version: '1.7.30'

我希望这会有所帮助。