# Elasticsearch-java dependency on httpclient

**URL:** https://discuss.elastic.co/t/elasticsearch-java-dependency-on-httpclient/322770
**Category:** Elasticsearch
**Created:** [January 9, 2023, 9:12pm UTC](https://discuss.elastic.co/t/elasticsearch-java-dependency-on-httpclient/322770 "2023-01-09T21:12:02Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![bbunton](https://avatars.discourse-cdn.com/v4/letter/b/a87d85/32.png) [@bbunton](https://discuss.elastic.co/u/bbunton)
#### Post date: [January 9, 2023, 9:12pm UTC](https://discuss.elastic.co/t/elasticsearch-java-dependency-on-httpclient/322770/1 "2023-01-09T21:12:02Z")

</div>

I have been working with Elasticsearch as a developer for a couple of years now and have successfully written some NiFi services that use the now deprecated Java API that uses port 9300 to query/retrieve/delete records to/from elasticsearch. I am currently undergoing an effort to migrate to the most recent elasticsearch-java API 8.5.3 which uses port 9200. The associated jar file depends on httpclient. In my pom.xml file, I am specifying httpclient 4.5.13 as I have seen some other traffic on the internet ([spring boot - elasticsearch java.lang.NoSuchMethodError: org.apache.http.client.utils.URLEncodedUtils.formatSegments - Stack Overflow](https://stackoverflow.com/questions/71725325/elasticsearch-java-lang-nosuchmethoderror-org-apache-http-client-utils-urlencod)) stating version 4.5.13 solves their problem that is very similar to the one I am experiencing.

Does anyone know the correct minimum version of httpclient that the Java API 8.5.3 requires to run properly?

Here is the relevant stack trace that I am experiencing:

```auto
java.lang.NoSuchMethodError: 'java.lang.String org.apache.http.client.utils.URLEncodedUtils.formatSegments(java.lang.String[])'
        at co.elastic.clients.transport.endpoints.SimpleEndpoint.pathEncode(SimpleEndpoint.java:91)
        at co.elastic.clients.elasticsearch.core.IndexRequest.lambda$static$2(IndexRequest.java:611)
        at co.elastic.clients.transport.endpoints.EndpointBase.requestUrl(EndpointBase.java:79)
        at co.elastic.clients.transport.rest_client.RestClientTransport.prepareLowLevelRequest(RestClientTransport.java:192)
        at co.elastic.clients.transport.rest_client.RestClientTransport.performRequest(RestClientTransport.java:146)
        at co.elastic.clients.elasticsearch.ElasticsearchClient.index(ElasticsearchClient.java:962)

```

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [January 9, 2023, 9:50pm UTC](https://discuss.elastic.co/t/elasticsearch-java-dependency-on-httpclient/322770/2 "2023-01-09T21:50:05Z")

</div>

> [@bbunton](#):
>
> Does anyone know the correct minimum version of httpclient that the Java API 8.5.3 requires to run properly?

As per

> <https://github.com/elastic/elasticsearch/blob/8.5/gradle/build.versions.toml#L20-L21>

> httpclient:4.5.10

@swallez might know more.

---

<div class="post-metadata">

### Author: ![bbunton](https://avatars.discourse-cdn.com/v4/letter/b/a87d85/32.png) [@bbunton](https://discuss.elastic.co/u/bbunton)
#### Post date: [January 9, 2023, 10:33pm UTC](https://discuss.elastic.co/t/elasticsearch-java-dependency-on-httpclient/322770/3 "2023-01-09T22:33:45Z")

</div>

Thank you!

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [February 6, 2023, 10:34pm UTC](https://discuss.elastic.co/t/elasticsearch-java-dependency-on-httpclient/322770/4 "2023-02-06T22:34:28Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
