Error instantiating SqsClient - Unable to load an HTTP implementation from any provider in the chain. You must declare a dependency on an appropriate HTTP implementation or pass in an SdkHttpClient explicitly to the client builder.
See original GitHub issueHi,
I am trying to instantiate SqsClient in my Scala project. When I build the image and deploy it in the EKS cluster, I keep getting the following error:
software.amazon.awssdk.core.exception.SdkClientException: Unable to load an HTTP implementation from any provider in the chain. You must declare a dependency on an appropriate HTTP implementation or pass in an SdkHttpClient explicitly to the client builder.
I am testing my code in EKS cluster where Pods are configured with ServiceAccount. I verified the two AWS_ROLE_ARN and AWS_WEB_IDENTITY_TOKEN_FILE environment variables are populated with valid values. Expecting the authentication to take place using the web identity token. I tried various version of AWS SDK from 2.10.11 onwards. Currently using the 2.13.9.
I am trying to instantiate SqsClient as shown below:
SqsClient.builder()
.region(Region.US_EAST_1)
.httpClient(ApacheHttpClient.builder().build())
.build()
Going by some suggestions in the other forums, I tried to instantiate WebIdentityTokenFileCredentialsProvider explicitly:
SqsClient.builder()
.region(Region.US_EAST_1)
.credentialsProvider(WebIdentityTokenFileCredentialsProvider.create())
.build()
Out sbt config:
libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.2.3"
libraryDependencies += "com.typesafe.scala-logging" %% "scala-logging" % "3.9.2"
libraryDependencies += "com.typesafe" % "config" % "1.3.3"
libraryDependencies += "software.amazon.awssdk" % "sqs" % "2.13.9"
//libraryDependencies += "software.amazon.awssdk" % "sts" % "2.13.9"
I have also tried to use the following in sbt which includes a libraries for various services:
libraryDependencies += "software.amazon.awssdk" % "aws-sdk-java" % "2.13.9"
Following is the exception stacktrace:
software.amazon.awssdk.core.exception.SdkClientException: Unable to load an HTTP implementation from any provider in the chain. You must declare a dependency on an appropriate HTTP implementation or pass in an SdkHttpClient explicitly to the client builder.
at software.amazon.awssdk.core.exception.SdkClientException$BuilderImpl.build(SdkClientException.java:98)
at software.amazon.awssdk.core.internal.http.loader.DefaultSdkHttpClientBuilder.lambda$buildWithDefaults$1(DefaultSdkHttpClientBuilder.java:49)
at java.util.Optional.orElseThrow(Optional.java:290)
at software.amazon.awssdk.core.internal.http.loader.DefaultSdkHttpClientBuilder.buildWithDefaults(DefaultSdkHttpClientBuilder.java:43)
at software.amazon.awssdk.core.client.builder.SdkDefaultClientBuilder.lambda$resolveSyncHttpClient$5(SdkDefaultClientBuilder.java:269)
at java.util.Optional.orElseGet(Optional.java:267)
at software.amazon.awssdk.core.client.builder.SdkDefaultClientBuilder.resolveSyncHttpClient(SdkDefaultClientBuilder.java:269)
at software.amazon.awssdk.core.client.builder.SdkDefaultClientBuilder.finalizeSyncConfiguration(SdkDefaultClientBuilder.java:220)
at software.amazon.awssdk.core.client.builder.SdkDefaultClientBuilder.syncClientConfiguration(SdkDefaultClientBuilder.java:153)
at software.amazon.awssdk.services.sqs.DefaultSqsClientBuilder.buildClient(DefaultSqsClientBuilder.java:27)
at software.amazon.awssdk.services.sqs.DefaultSqsClientBuilder.buildClient(DefaultSqsClientBuilder.java:22)
at software.amazon.awssdk.core.client.builder.SdkDefaultClientBuilder.build(SdkDefaultClientBuilder.java:124)
Environment
- AWS Java SDK version used: 2.13.9
- JDK version used: 1.8
- Scala : 2.12.10
- Kubernetes: 1.15
- Operating System and version: Amazon Linux 2
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (7 by maintainers)
Hmm, that’s odd. Could you try setting the system property as follows?
Closing this, feel free to reopen if there’s any further question.