aws-sdk-java-v2: LambdaConversionException: Invalid receiver type interface org.apache.http.Header; not a subtype of implementation type interface org.apache.http.NameValuePair

Hi there,

I’m trying to use the cloudsearchdomain service, especially the SwitchToPostInterceptor.

Expected Behavior

Using the CloudSearchDomainClient, I’m trying to upload documents to an existing instance. I expect an HTTP-Response with status code 200, which should be mapped to the Java type SearchResponse.

Current Behavior

Unfortunately, the mapping of the response to the Java type does not seem to work. The method call ends with the exception listed below:

Stacktrace:

java.lang.BootstrapMethodError: call site initialization exception
	at java.lang.invoke.CallSite.makeSite(CallSite.java:341)
	at java.lang.invoke.MethodHandleNatives.linkCallSiteImpl(MethodHandleNatives.java:307)
	at java.lang.invoke.MethodHandleNatives.linkCallSite(MethodHandleNatives.java:297)
	at software.amazon.awssdk.http.apache.ApacheHttpClient.transformHeaders(ApacheHttpClient.java:234)
	at software.amazon.awssdk.http.apache.ApacheHttpClient.createResponse(ApacheHttpClient.java:223)
	at software.amazon.awssdk.http.apache.ApacheHttpClient.execute(ApacheHttpClient.java:201)
	at software.amazon.awssdk.http.apache.ApacheHttpClient.access$400(ApacheHttpClient.java:92)
	at software.amazon.awssdk.http.apache.ApacheHttpClient$1.call(ApacheHttpClient.java:178)
	at software.amazon.awssdk.http.apache.ApacheHttpClient$1.call(ApacheHttpClient.java:175)
	at software.amazon.awssdk.core.internal.http.pipeline.stages.MakeHttpRequestStage.executeHttpRequest(MakeHttpRequestStage.java:58)
	at software.amazon.awssdk.core.internal.http.pipeline.stages.MakeHttpRequestStage.execute(MakeHttpRequestStage.java:50)
	at software.amazon.awssdk.core.internal.http.pipeline.stages.MakeHttpRequestStage.execute(MakeHttpRequestStage.java:34)
	at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:205)
	at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:205)
	at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:205)
	at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:205)
	at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:205)
	at software.amazon.awssdk.core.internal.http.pipeline.stages.RetryableStage$RetryExecutor.doExecute(RetryableStage.java:145)
	at software.amazon.awssdk.core.internal.http.pipeline.stages.RetryableStage$RetryExecutor.execute(RetryableStage.java:111)
	at software.amazon.awssdk.core.internal.http.pipeline.stages.RetryableStage.execute(RetryableStage.java:69)
	at software.amazon.awssdk.core.internal.http.pipeline.stages.RetryableStage.execute(RetryableStage.java:49)
	at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:205)
	at software.amazon.awssdk.core.internal.http.StreamManagingStage.execute(StreamManagingStage.java:57)
	at software.amazon.awssdk.core.internal.http.StreamManagingStage.execute(StreamManagingStage.java:42)
	at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:205)
	at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:205)
	at software.amazon.awssdk.core.internal.http.pipeline.stages.ExecutionFailureExceptionReportingStage.execute(ExecutionFailureExceptionReportingStage.java:37)
	at software.amazon.awssdk.core.internal.http.pipeline.stages.ExecutionFailureExceptionReportingStage.execute(ExecutionFailureExceptionReportingStage.java:25)
	at software.amazon.awssdk.core.internal.http.AmazonSyncHttpClient$RequestExecutionBuilderImpl.execute(AmazonSyncHttpClient.java:283)
	at software.amazon.awssdk.core.client.handler.BaseSyncClientHandler.invoke(BaseSyncClientHandler.java:91)
	at software.amazon.awssdk.core.client.handler.BaseSyncClientHandler.execute(BaseSyncClientHandler.java:103)
	at software.amazon.awssdk.core.client.handler.BaseSyncClientHandler.execute(BaseSyncClientHandler.java:68)
	at software.amazon.awssdk.core.client.handler.SdkSyncClientHandler.execute(SdkSyncClientHandler.java:44)
	at software.amazon.awssdk.awscore.client.handler.AwsSyncClientHandler.execute(AwsSyncClientHandler.java:53)
	at software.amazon.awssdk.services.cloudsearchdomain.DefaultCloudSearchDomainClient.search(DefaultCloudSearchDomainClient.java:124)
        ...
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
	at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
	at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
	at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
	at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)
Caused by: java.lang.invoke.LambdaConversionException: Invalid receiver type interface org.apache.http.Header; not a subtype of implementation type interface org.apache.http.NameValuePair
	at java.lang.invoke.AbstractValidatingLambdaMetafactory.validateMetafactoryArgs(AbstractValidatingLambdaMetafactory.java:233)
	at java.lang.invoke.LambdaMetafactory.metafactory(LambdaMetafactory.java:303)
	at java.lang.invoke.CallSite.makeSite(CallSite.java:302)
	... 67 more

Debug Log:

16:17:55 DEBUG software.amazon.awssdk.core.internal.interceptor.ExecutionInterceptorChain - Creating an interceptor chain that will apply interceptors in the following order: [software.amazon.awssdk.services.cloudsearchdomain.SwitchToPostInterceptor@476febb4]
16:17:55 DEBUG software.amazon.awssdk.request - Sending Request: software.amazon.awssdk.http.DefaultSdkHttpFullRequest@6f088727
16:17:55 DEBUG software.amazon.awssdk.auth.signer.Aws4Signer - AWS4 Canonical Request: '"POST
/2013-01-01/documents/batch
format=sdk
amz-sdk-invocation-id:0700c94d-c5c9-e686-ad10-d76b8ffa0054
amz-sdk-retry:0/0/500
content-length:8020
content-type:application/json
host:xxx.eu-central-1.cloudsearch.amazonaws.com
user-agent:aws-sdk-java/2.0.0-preview-11 Linux/4.13.0-46-generic Java_HotSpot_TM__64-Bit_Server_VM/25.131-b11 Java/1.8.0_131
x-amz-date:20180808T141755Z
x-amz-security-token:***

amz-sdk-invocation-id;amz-sdk-retry;content-length;content-type;host;user-agent;x-amz-date;x-amz-security-token
fba44c92bd49b8d9ce31e0945a925335340dbe2b08cb4da1ea5ace03660afd98"
16:17:55 DEBUG software.amazon.awssdk.auth.signer.Aws4Signer - AWS4 String to Sign: '"AWS4-HMAC-SHA256
20180808T141755Z
20180808/eu-central-1/cloudsearch/aws4_request
8c31ba19f25a532bb190f6f6aa6ecbf7a523308f87b048e366d0b3f296503215"
16:17:55 DEBUG software.amazon.awssdk.auth.signer.Aws4Signer - Generating a new signing key as the signing key not available in the cache for the date 1533686400000
16:17:55 DEBUG org.apache.http.client.protocol.RequestAddCookies - CookieSpec selected: default
16:17:55 DEBUG org.apache.http.client.protocol.RequestAuthCache - Auth cache not set in the context
16:17:55 DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection request: [route: {s}->https://xxx.eu-central-1.cloudsearch.amazonaws.com:443][total kept alive: 0; route allocated: 0 of 50; total allocated: 0 of 50]
16:17:55 DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection leased: [id: 0][route: {s}->https://xxx.eu-central-1.cloudsearch.amazonaws.com:443][total kept alive: 0; route allocated: 1 of 50; total allocated: 1 of 50]
16:17:55 DEBUG org.apache.http.impl.execchain.MainClientExec - Opening connection {s}->https://xxx.eu-central-1.cloudsearch.amazonaws.com:443
16:17:55 DEBUG org.apache.http.impl.conn.DefaultHttpClientConnectionOperator - Connecting to xxx.eu-central-1.cloudsearch.amazonaws.com/18.194.72.147:443
16:17:55 DEBUG software.amazon.awssdk.http.apache.internal.conn.SdkTlsSocketFactory - Connecting to xxx.eu-central-1.cloudsearch.amazonaws.com/18.194.72.147:443
16:17:55 DEBUG software.amazon.awssdk.http.apache.internal.conn.SdkTlsSocketFactory - Connecting socket to xxx.eu-central-1.cloudsearch.amazonaws.com/18.194.72.147:443 with timeout 2000
16:17:55 DEBUG software.amazon.awssdk.http.apache.internal.conn.SdkTlsSocketFactory - Enabled protocols: [TLSv1, TLSv1.1, TLSv1.2]
16:17:55 DEBUG software.amazon.awssdk.http.apache.internal.conn.SdkTlsSocketFactory - Enabled cipher suites:[TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_DSS_WITH_AES_128_GCM_SHA256, TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_RSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA, TLS_EMPTY_RENEGOTIATION_INFO_SCSV]
16:17:55 DEBUG software.amazon.awssdk.http.apache.internal.conn.SdkTlsSocketFactory - socket.getSupportedProtocols(): [SSLv2Hello, SSLv3, TLSv1, TLSv1.1, TLSv1.2], socket.getEnabledProtocols(): [TLSv1, TLSv1.1, TLSv1.2]
16:17:55 DEBUG software.amazon.awssdk.http.apache.internal.conn.SdkTlsSocketFactory - TLS protocol enabled for SSL handshake: [TLSv1.2, TLSv1.1, TLSv1]
16:17:55 DEBUG software.amazon.awssdk.http.apache.internal.conn.SdkTlsSocketFactory - Starting handshake
16:17:55 DEBUG software.amazon.awssdk.http.apache.internal.conn.SdkTlsSocketFactory - Secure session established
16:17:55 DEBUG software.amazon.awssdk.http.apache.internal.conn.SdkTlsSocketFactory -  negotiated protocol: TLSv1.2
16:17:55 DEBUG software.amazon.awssdk.http.apache.internal.conn.SdkTlsSocketFactory -  negotiated cipher suite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
16:17:55 DEBUG software.amazon.awssdk.http.apache.internal.conn.SdkTlsSocketFactory -  peer principal: CN=*.eu-central-1.cloudsearch.amazonaws.com
16:17:55 DEBUG software.amazon.awssdk.http.apache.internal.conn.SdkTlsSocketFactory -  peer alternative names: [*.eu-central-1.cloudsearch.amazonaws.com]
16:17:55 DEBUG software.amazon.awssdk.http.apache.internal.conn.SdkTlsSocketFactory -  issuer principal: CN=Amazon, OU=Server CA 1B, O=Amazon, C=US
16:17:55 DEBUG software.amazon.awssdk.http.apache.internal.net.SdkSslSocket - created: xxx.eu-central-1.cloudsearch.amazonaws.com/18.194.72.147:443
16:17:55 DEBUG org.apache.http.impl.conn.DefaultHttpClientConnectionOperator - Connection established 172.19.40.86:37986<->18.194.72.147:443
16:17:55 DEBUG org.apache.http.impl.conn.DefaultManagedHttpClientConnection - http-outgoing-0: set socket timeout to 30000
16:17:55 DEBUG org.apache.http.impl.execchain.MainClientExec - Executing request POST /2013-01-01/documents/batch?format=sdk HTTP/1.1
16:17:55 DEBUG org.apache.http.impl.execchain.MainClientExec - Proxy auth state: UNCHALLENGED
16:17:55 DEBUG org.apache.http.headers - http-outgoing-0 >> POST /2013-01-01/documents/batch?format=sdk HTTP/1.1
16:17:55 DEBUG org.apache.http.headers - http-outgoing-0 >> Host: xxx.eu-central-1.cloudsearch.amazonaws.com
16:17:55 DEBUG org.apache.http.headers - http-outgoing-0 >> amz-sdk-invocation-id: 0700c94d-c5c9-e686-ad10-d76b8ffa0054
16:17:55 DEBUG org.apache.http.headers - http-outgoing-0 >> amz-sdk-retry: 0/0/500
16:17:55 DEBUG org.apache.http.headers - http-outgoing-0 >> Authorization: AWS4-HMAC-SHA256 Credential=ASIA2OY2NTFI6VYH6DWD/20180808/eu-central-1/cloudsearch/aws4_request, SignedHeaders=amz-sdk-invocation-id;amz-sdk-retry;content-length;content-type;host;user-agent;x-amz-date;x-amz-security-token, Signature=5a24a10fd044d3856fe6c215bb4b1803e9c47d14d082f8137d5c1e330524e5c0
16:17:55 DEBUG org.apache.http.headers - http-outgoing-0 >> Content-Type: application/json
16:17:55 DEBUG org.apache.http.headers - http-outgoing-0 >> User-Agent: aws-sdk-java/2.0.0-preview-11 Linux/4.13.0-46-generic Java_HotSpot_TM__64-Bit_Server_VM/25.131-b11 Java/1.8.0_131
16:17:55 DEBUG org.apache.http.headers - http-outgoing-0 >> X-Amz-Date: 20180808T141755Z
16:17:55 DEBUG org.apache.http.headers - http-outgoing-0 >> X-Amz-Security-Token: ***
16:17:55 DEBUG org.apache.http.headers - http-outgoing-0 >> Content-Length: 8020
16:17:55 DEBUG org.apache.http.headers - http-outgoing-0 >> Connection: Keep-Alive
16:17:55 DEBUG org.apache.http.wire - http-outgoing-0 >> "POST /2013-01-01/documents/batch?format=sdk HTTP/1.1[\r][\n]"
16:17:55 DEBUG org.apache.http.wire - http-outgoing-0 >> "Host: xxx.eu-central-1.cloudsearch.amazonaws.com[\r][\n]"
16:17:55 DEBUG org.apache.http.wire - http-outgoing-0 >> "amz-sdk-invocation-id: 0700c94d-c5c9-e686-ad10-d76b8ffa0054[\r][\n]"
16:17:55 DEBUG org.apache.http.wire - http-outgoing-0 >> "amz-sdk-retry: 0/0/500[\r][\n]"
16:17:55 DEBUG org.apache.http.wire - http-outgoing-0 >> "Authorization: AWS4-HMAC-SHA256 Credential=ASIA2OY2NTFI6VYH6DWD/20180808/eu-central-1/cloudsearch/aws4_request, SignedHeaders=amz-sdk-invocation-id;amz-sdk-retry;content-length;content-type;host;user-agent;x-amz-date;x-amz-security-token, Signature=5a24a10fd044d3856fe6c215bb4b1803e9c47d14d082f8137d5c1e330524e5c0[\r][\n]"
16:17:55 DEBUG org.apache.http.wire - http-outgoing-0 >> "Content-Type: application/json[\r][\n]"
16:17:55 DEBUG org.apache.http.wire - http-outgoing-0 >> "User-Agent: aws-sdk-java/2.0.0-preview-11 Linux/4.13.0-46-generic Java_HotSpot_TM__64-Bit_Server_VM/25.131-b11 Java/1.8.0_131[\r][\n]"
16:17:55 DEBUG org.apache.http.wire - http-outgoing-0 >> "X-Amz-Date: 20180808T141755Z[\r][\n]"
16:17:55 DEBUG org.apache.http.wire - http-outgoing-0 >> "X-Amz-Security-Token:***[\r][\n]"
16:17:55 DEBUG org.apache.http.wire - http-outgoing-0 >> "Content-Length: 8020[\r][\n]"
16:17:55 DEBUG org.apache.http.wire - http-outgoing-0 >> "Connection: Keep-Alive[\r][\n]"
16:17:55 DEBUG org.apache.http.wire - http-outgoing-0 >> "[\r][\n]"
16:17:55 DEBUG org.apache.http.wire - http-outgoing-0 >> "*** SOME JSON BODY ***"
16:17:55 DEBUG org.apache.http.wire - http-outgoing-0 << "HTTP/1.1 200 OK[\r][\n]"
16:17:55 DEBUG org.apache.http.wire - http-outgoing-0 << "Content-Type: application/json; charset=utf-8[\r][\n]"
16:17:55 DEBUG org.apache.http.wire - http-outgoing-0 << "Date: Wed, 08 Aug 2018 14:17:55 GMT[\r][\n]"
16:17:55 DEBUG org.apache.http.wire - http-outgoing-0 << "x-amzn-RequestId: d8033f0d-9b15-11e8-aaee-5b329507b6e9[\r][\n]"
16:17:55 DEBUG org.apache.http.wire - http-outgoing-0 << "Content-Length: 46[\r][\n]"
16:17:55 DEBUG org.apache.http.wire - http-outgoing-0 << "Connection: keep-alive[\r][\n]"
16:17:55 DEBUG org.apache.http.wire - http-outgoing-0 << "[\r][\n]"
16:17:55 DEBUG org.apache.http.wire - http-outgoing-0 << "{"status": "success", "adds": 1, "deletes": 0}"
16:17:55 DEBUG org.apache.http.headers - http-outgoing-0 << HTTP/1.1 200 OK
16:17:55 DEBUG org.apache.http.headers - http-outgoing-0 << Content-Type: application/json; charset=utf-8
16:17:55 DEBUG org.apache.http.headers - http-outgoing-0 << Date: Wed, 08 Aug 2018 14:17:55 GMT
16:17:55 DEBUG org.apache.http.headers - http-outgoing-0 << x-amzn-RequestId: d8033f0d-9b15-11e8-aaee-5b329507b6e9
16:17:55 DEBUG org.apache.http.headers - http-outgoing-0 << Content-Length: 46
16:17:55 DEBUG org.apache.http.headers - http-outgoing-0 << Connection: keep-alive
16:17:55 DEBUG org.apache.http.impl.execchain.MainClientExec - Connection can be kept alive for 60000 MILLISECONDS

Steps to Reproduce (for bugs)

In Maven POM (among other dependencies of [aws-sdk-java|https://github.com/aws/aws-sdk-java]):

        <dependency>
            <groupId>software.amazon.awssdk</groupId>
            <artifactId>cloudsearchdomain</artifactId>
            <version>2.0.0-preview-11</version>
        </dependency>

DomainClient configuration:

CloudSearchDomainClient.builder()
                .endpointOverride(URI.create(cs_document_endpoint))
                .credentialsProvider(cp)
                .build();

UploadDocument operation:

         JSONArray batch = ...;
         byte[] batchAsBytes = batch.toString().getBytes();
        RequestBody requestBody = RequestBody.fromBytes(batchAsBytes);

        UploadDocumentsRequest uploadDocumentsRequest = UploadDocumentsRequest.builder()
                .contentLength(Long.valueOf(batchAsBytes.length))
                .contentType(ContentType.APPLICATION_JSON)
                .build();

        UploadDocumentsResponse result = domain.uploadDocuments(uploadDocumentsRequest,
                requestBody);

Context

As mentioned above, I’m already using the aws-sdk-java CloudSearch client. However, I want to take advantage of the usage of POST as HTTP-Method for every request.

Your Environment

  • AWS Java SDK version used: 2.0.0-preview-11
  • JDK version used: jdk1.8.0_131
  • Maven version: Apache Maven 3.5.4
  • Spring-Boot version: 1.4.5.RELEASE
  • Spring-Cloud version: Camden.SR5
  • Operating System and version: OS name: “linux”, version: “4.13.0-46-generic”, arch: “amd64”, family: “unix”

Looking forward to an answer and thanks in advance, Alex

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 15
  • Comments: 42 (3 by maintainers)

Commits related to this issue

Most upvoted comments

The problem can be fixed forcing <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpcore</artifactId> <version>4.4.9</version> </dependency>

From 4.4.9 changelog

  • HTTPCORE-499: Make interface Header extend NameValuePair.

Looks like the suggestion to import http-client resolved the issue:

<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
<dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpclient</artifactId>
    <version>4.5.5</version>
</dependency>

For some reason I thought that amazon provided shaded versions of the dependencies so these types of conflicts don’t occur, but maybe that’s not the case here…

I have the same problem with S3Client.getObject @alxgrk

Is there any particular reason that the sdk doesn’t declare a dependency on the range of httpcore versions that it relies on (in their pom)? Then maven dependency management would just download the highest version that otherwise works with a user’s project (or error out if no common version exists between what I specify in my pom for my project’s other needs and the version range supported by the aws sdk). If my project doesn’t otherwise rely on httpcore, there’s no conflict, and Maven would just include the latest httpcore in the version range specified by the aws sdk.

I’ve never actually done something like that, so maybe there’s a reason why that’s not possible. But I thought Maven supported version ranges for cases like this.

I feel like consumers of the sdk shouldn’t have to deal with this.

@mguillet Tried this out with no luck. I do have deps in httpcomponents to resolve dependency conflicts for my project:

        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.6</version>
        </dependency>

        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpcore</artifactId>
            <version>4.4.10</version>
        </dependency>

Hey @debora-ito, unfortunately i’ve never got it working… I don’t even remember in detail, but i think i just used a totally different approach to solve my problem.

From my side, this issue can be closed, since there are some suggested solutions.

My previous answers gives the definitive solution to this problem. Step to fix it once and for all

  1. Move http-core 4.4.9 or later version
  2. Prevent any transitive dependency on http-core versions
  3. Check your distribution file, .war or .jar, to be sure that only the correct version of http-core is in there. If all these steps have been done, no way to get this error any more Why we need previous steps? In 4.9.9 and later versions org.apache.http.Header implements the interface org.apache.http.NameValuePair and this excludes the possibility to rise this exception.

I ran into this issue with software.amazon.awssdk:bom:2.5.51 using software.amazon.awssdk:ssm. I wasn’t able to resolve it using the exclusion and explicit dependencies described above.

I was able to resolve it by making awssdk first in my <dependencies> section. I was then able to remove the exclusions and explicit dependencies.

My previous answers gives the definitive solution to this problem. Step to fix it once and for all

  1. Move http-core 4.4.9 or later version
  2. Prevent any transitive dependency on http-core versions
  3. Check your distribution file, .war or .jar, to be sure that only the correct version of http-core is in there. If all these steps have been done, no way to get this error any more Why we need previous steps? In 4.9.9 and later versions org.apache.http.Header implements the interface org.apache.http.NameValuePair and this excludes the possibility to rise this exception.

it worked

2019-12-20 03:51:12.488 WARN 29453 — [nio-8271-exec-1] s.a.a.h.a.internal.utils.ApacheUtils : NoSuchMethodException was thrown when disabling normalizeUri. This indicates you are using an old version (< 4.5.8) of Apache http client. It is recommended to use http client version >= 4.5.9 to avoid the breaking change introduced in apache client 4.5.7 and the latency in exception handling. See https://github.com/aws/aws-sdk-java/issues/1919 for more information