# ElasticSearch 8.5 and Java Client Error ""com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'Client'

**URL:** <https://discuss.elastic.co/t/elasticsearch-8-5-and-java-client-error-com-fasterxml-jackson-core-jsonparseexception-unrecognized-token-client/319700>\
**Category:** Elasticsearch\
**Created:** [November 24, 2022, 5:15am UTC](https://discuss.elastic.co/t/elasticsearch-8-5-and-java-client-error-com-fasterxml-jackson-core-jsonparseexception-unrecognized-token-client/319700 "2022-11-24T05:15:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![AlwaysBatMan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alwaysbatman/32/113706_2.png) [@AlwaysBatMan](https://discuss.elastic.co/u/AlwaysBatMan)\
**Post date:** [November 24, 2022, 5:15am UTC](https://discuss.elastic.co/t/elasticsearch-8-5-and-java-client-error-com-fasterxml-jackson-core-jsonparseexception-unrecognized-token-client/319700/1 "2022-11-24T05:15:27Z")

</div>

I am trying to use Elasticsearch 8.5 and its associated RestClient.I am having some difficulties using it and I am not able to make sense of this as to why this error message will be thrown.Looking for some guidance on how to move ahead on this.

```auto
 <dependency>
            <groupId>co.elastic.clients</groupId>
            <artifactId>elasticsearch-java</artifactId>
            <version>8.5.1</version>
            
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.13.3</version>
        </dependency>

```

```auto
RestClientBuilder builder = RestClient.builder(
                        new HttpHost("somehost", 443))
                .setHttpClientConfigCallback(httpClientBuilder -> httpClientBuilder
                        .setDefaultCredentialsProvider(credentialsProvider));

        RestClient restClient = builder.build();

        System.out.println(restClient.getNodes());
        System.out.println(restClient.isRunning());

        try{

        ElasticsearchTransport transport = new RestClientTransport(
                restClient,
                new JacksonJsonpMapper()
        );

        ElasticsearchClient esClient = new ElasticsearchClient(transport);

           // IndexRequest<Profile> request=new IndexRequest.Builder<Profile>().index("");

      // esClient.index()
            //index th edata first
// User user=new User("Bhanu","Marwaha");
//
// IndexResponse response = esClient.index(i -> i
// .index("user")
// .id("1")
// .document(user)
// );

            TermQuery termQuery= QueryBuilders.term().field("title").value("Rocky Mountain").build();
     SearchRequest searchRequest = new SearchRequest.Builder().index("search-profile").query(termQuery._toQuery())
                .build();
            SearchResponse<Places> response=null;

            try {
               response= esClient.search(searchRequest, Places.class);
                response.hits().hits().stream().forEach(modelHit -> System.out.println(modelHit.source().getVisitors()));

            }

```

```
<dependency>
        <groupId>co.elastic.clients</groupId>
        <artifactId>elasticsearch-java</artifactId>
        <version>8.5.1</version>
    </dependency>

    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.13.3</version>
    </dependency>

```

Error I get:

```auto
Caused by: com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'Client': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')
 at [Source: (ByteArrayInputStream); line: 1, column: 8]
	at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:2391)
	at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:745)
	at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._reportInvalidToken(UTF8StreamJsonParser.java:3635)
	at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._handleUnexpectedValue(UTF8StreamJsonParser.java:2734)
	at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._nextTokenNotInObject(UTF8StreamJsonParser.java:902)
	at com.fasterxml.jackson.core.json.UTF8StreamJsonParser.nextToken(UTF8StreamJsonParser.java:794)
	at co.elastic.clients.json.jackson.JacksonJsonpParser.fetchNextToken(JacksonJsonpParser.java:89)
	... 8 more

```

---

<div class="post-metadata">

**Author:** ![AlwaysBatMan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alwaysbatman/32/113706_2.png) [@AlwaysBatMan](https://discuss.elastic.co/u/AlwaysBatMan)\
**Post date:** [November 25, 2022, 7:56am UTC](https://discuss.elastic.co/t/elasticsearch-8-5-and-java-client-error-com-fasterxml-jackson-core-jsonparseexception-unrecognized-token-client/319700/2 "2022-11-25T07:56:38Z")

</div>

I guess this API is still in dev phase and not GA.When I debugged the code and went through library classes it showed and response of 400 that is Bad request.Now I don't know how and why it is showing me a bad request  
private Response performRequest(final NodeTuple\<Iterator\> tuple, final InternalRequest request, Exception previousException)  
Class RestClient  
httpResponse = client.execute(context.requestProducer, context.asyncResponseConsumer, context.context, null).get();  
Library builds following request and sends ignore without me setting this in...,making the whole debugging bit more difficult than it really is..

Request{method='POST', endpoint='/search-profile/\_search', params={typed\_keys=true, ignore=400,401,403,404,405}, entity=[Content-Type: application/vnd.elasticsearch+json; compatible-with=8,Content-Length: 56,Chunked: false], options=RequestOptions{headers=X-Elastic-Client-Meta: es=8.5.1,jv=19,hl=2,t=8.5.1,hc=4.1.5,User-Agent: elastic-java/8.5.1 (Java/19.0.1),Accept: application/vnd.elasticsearch+json; compatible-with=8}}

Response I get:

HTTP/1.0 400 Bad Request [Chunked: false]

---

<div class="post-metadata">

**Author:** ![Philip\_Bannon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/philip_bannon/32/101377_2.png) [@Philip\_Bannon](https://discuss.elastic.co/u/Philip_Bannon)\
**Post date:** [November 28, 2022, 10:27pm UTC](https://discuss.elastic.co/t/elasticsearch-8-5-and-java-client-error-com-fasterxml-jackson-core-jsonparseexception-unrecognized-token-client/319700/3 "2022-11-28T22:27:43Z")

</div>

> [@AlwaysBatMan](#):
>
> `databind`

Also getting the same error.

---

<div class="post-metadata">

**Author:** ![AlwaysBatMan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alwaysbatman/32/113706_2.png) [@AlwaysBatMan](https://discuss.elastic.co/u/AlwaysBatMan)\
**Post date:** [December 10, 2022, 10:34am UTC](https://discuss.elastic.co/t/elasticsearch-8-5-and-java-client-error-com-fasterxml-jackson-core-jsonparseexception-unrecognized-token-client/319700/4 "2022-12-10T10:34:05Z")

</div>

> [@AlwaysBatMan](#):
>
> Request{method='POST', endpoint='/search-profile/\_search', params={typed\_keys=true, ignore=400,401,403,404,405}, entity=[Content-Type: application/vnd.elasticsearch+json; compatible-with=8,Content-Length: 56,Chunked: false], options=RequestOptions{headers=X-Elastic-Client-Meta: es=8.5.1,jv=19,hl=2,t=8.5.1,hc=4.1.5,User-Agent: elastic-java/8.5.1 (Java/19.0.1),Accept: application/vnd.elasticsearch+json; compatible-with=8}}

any answer for this?

---

<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:** [January 7, 2023, 10:34am UTC](https://discuss.elastic.co/t/elasticsearch-8-5-and-java-client-error-com-fasterxml-jackson-core-jsonparseexception-unrecognized-token-client/319700/5 "2023-01-07T10:34:55Z")

</div>

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