Fixing Apache HTTP client dependencies when working with the AWS SDK v2 for Java

Originally posted on 2020-11-09

If you're using the AWS SDK v2 for Java you may have run into this error message:

WARN - 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 for more information

This message is sometimes followed by this:

call site initialization exception
java.lang.BootstrapMethodError: call site initialization exception
	at java.lang.invoke.CallSite.makeSite(

You might be saying that you've already set your HTTP client version to something greater than 4.5.9 as they requested. You might also see that most of your dependencies are actually using it. However, in my experience this is caused by transitive dependencies somehow forcing an older version.

There is a fix though. If you're using Gradle and the Kotlin DSL you can add this to your build.gradle.kts:

configurations.all {
    // Don't allow any configuration to use a broken version of HTTP client

This is what finally worked for me 100% of the time. I tried using the strictly option on my dependencies but it never seemed to stick. There were some other tricks I tried that did work but they were messy (e.g. the reject option sometimes worked).

In any case, this should do it. Go and develop!