简体   繁体   English

AmazonSQSClientBuilder.defaultClient() java.lang.NoSuchFieldError: No static Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier 类型的字段实例

[英]AmazonSQSClientBuilder.defaultClient() java.lang.NoSuchFieldError: No static field INSTANCE of type Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.msgqueue3/com.example.msgqueue3.MainActivity}: java.lang.NullPointerException: Attempt to invoke interface method 'com.amazonaws.services.sqs.model.CreateQueueResult com.amazonaws.services.sqs.AmazonSQS.createQueue(com.amazonaws.services.sqs.model.CreateQueueRequest)' on a null object reference java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.msgqueue3/com.example.msgqueue3.MainActivity}: java.lang.NullPointerException: Attempt to invoke interface method 'com.amazonaws.services.sqs.model.CreateQueueResult com.amazonaws.services.sqs.AmazonSQS.createQueue(com.amazonaws.services.sqs.model.CreateQueueRequest)' on a null object reference

AWS SQS connection problem AWS SQS 连接问题

I suggest to use the AWS Java SDK V2 .我建议使用 AWS Java SDK V2 It will allow you to use an alternate HTTP runtime, and avoid some of the mess with the Apache client, when working on Android.在 Android 上工作时,它将允许您使用备用 HTTP 运行时,并避免 Apache 客户端的一些混乱。

GitHub Issue #1180 in the AWS Java SDK V2 repo addresses this topic. AWS Java SDK V2 存储库中的GitHub 问题 #1180解决了此主题。

Specifically, in your module-level build.gradle , add dependencies:具体来说,在您的模块级build.gradle中,添加依赖项:

dependencies {
    implementation 'software.amazon.awssdk:sqs:2.13.49'
    implementation 'software.amazon.awssdk:url-connection-client:2.13.49'
}

Now, initialize the SQS client:现在,初始化 SQS 客户端:

val sqs = SqsClient.builder()
    .httpClient(UrlConnectionHttpClient.create())
    .region(Region.US_EAST_1)
    .credentialsProvider(yourCredentialsHere())
    .build()

its working.它的工作。

     ProfileCredentialsProvider credentialsProvider = new ProfileCredentialsProvider();

    try {

        credentialsProvider.getCredentials();
    } catch (Exception e) {
        throw new AmazonClientException(
                "Cannot load the credentials from the credential profiles file. " +
                        "Please make sure that your credentials file is at the correct " +
                        "location (~/.aws/credentials), and is in valid format.",
                e);

    }
    AmazonSQS sqs = AmazonSQSClientBuilder.standard()
            .withCredentials(credentialsProvider)
            .withRegion(Regions.US_WEST_2)
            .build();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 Android Studio 项目中使用 htmlunit 时,没有 Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier 类型的 static 字段实例 - No static field INSTANCE of type Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier when using htmlunit in Android Studio Project HTTPClient“主要” java.lang.NoSuchFieldError:实例位于org.apache.http.conn.ssl.SSLConnectionSocketFactory。 <clinit> - HTTPClient “main” java.lang.NoSuchFieldError: INSTANCE at org.apache.http.conn.ssl.SSLConnectionSocketFactory.<clinit> java.lang.NoSuchFieldError:INSTANCE - java.lang.NoSuchFieldError: INSTANCE java.lang.NoSuchFieldError: org.apache.http.message.BasicLineFormatter.INSTANCE 来自 Java 应用程序中的 Mashape Unirest - java.lang.NoSuchFieldError: org.apache.http.message.BasicLineFormatter.INSTANCE from Mashape Unirest in Java application Apache httpclient 4.3.1 java.lang.NoSuchFieldError:INSTANCE - Apache httpclient 4.3.1 java.lang.NoSuchFieldError: INSTANCE java.lang.NoSuchFieldError:类型为Lcom / google / android / gms / internal / zzsb $ zzb的静态字段KL - java.lang.NoSuchFieldError: No static field KL of type Lcom/google/android/gms/internal/zzsb$zzb HttpClientBuilder - java.lang.NoSuchFieldError:INSTANCE - HttpClientBuilder - java.lang.NoSuchFieldError: INSTANCE java.lang.NoSuchFieldError:bitpay SDK中的INSTANCE - java.lang.NoSuchFieldError: INSTANCE in bitpay SDK mongodb中的错误:java.lang.NoSuchFieldError:INSTANCE - Error in mongodb: java.lang.NoSuchFieldError: INSTANCE HtmlUnit java.lang.NoSuchFieldError: 实例 - HtmlUnit java.lang.NoSuchFieldError: INSTANCE
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM