"Failed to decode response" error from Java Client 8.8.0

Hello:

I am trying to use Elastic Java Client 8.8.0 (also known low-level rest client) and getting the error: status: 200, [es/search] Failed to decode response

I used the same library to create a new index and insert a new document and using the same POJO class to deserialize the document, found in the index, however no avail.

Here's the code fragment:

        patDocument.setAddendum("abc");
        patDocument.setDocumentName("docName");
        patDocument.setAuthorName("RK");
        patDocument.setId(3);
        try {
            IndexResponse response = esClient.index(i -> i
                    .index("patdocument-xxx")
                    .id(patDocument.getId() + "")
                    .document(patDocument)
            );
        } catch (IOException e) {
            System.err.println(e.getMessage());
        }

        // ======= searching documents =======
        SearchResponse<PatDocument2> response3=null;

        try {
            response3 = esClient.search(s -> s.index("patdocument-xxx")
                    .query(q -> q.match(t -> t.field("id").query("3"))), PatDocument2.class);
        } catch (IOException e) {
            System.err.println(e.getMessage());
        }
        System.out.println(response3);```

and this is the part of POJO:
private String addendum;
private String authorName;
private String documentName;
private Boolean draft;
private Integer id;

Thanks a lot in advance.

Kindly,

Roman

Could you share the full stack trace please?

node: https://OBSCURED_URL:9443/, status: 200, [es/search] Failed to decode response

Could you share the full stack trace please?

co.elastic.clients.transport.TransportException: node: https://xxx:9443/, status: 200, [es/index] Failed to decode response
at co.elastic.clients.transport.ElasticsearchTransportBase.decodeTransportResponse(ElasticsearchTransportBase.java:345)
at co.elastic.clients.transport.ElasticsearchTransportBase.getApiResponse(ElasticsearchTransportBase.java:304)
at co.elastic.clients.transport.ElasticsearchTransportBase.performRequest(ElasticsearchTransportBase.java:111)
at co.elastic.clients.elasticsearch.ElasticsearchClient.index(ElasticsearchClient.java:1121)
at co.elastic.clients.elasticsearch.ElasticsearchClient.index(ElasticsearchClient.java:1138)
at Main.main(Main.java:53)
Caused by: co.elastic.clients.json.JsonpMappingException: Error deserializing co.elastic.clients.elasticsearch._types.ShardStatistics: jakarta.json.JsonException: Unable to get a JsonProvider. Check your classpath or thread context classloader. (JSON path: _shards.total) (line no=1, column no=91, offset=-1)
at co.elastic.clients.json.JsonpMappingException.from0(JsonpMappingException.java:134)
at co.elastic.clients.json.JsonpMappingException.from(JsonpMappingException.java:121)
at co.elastic.clients.json.ObjectDeserializer.deserialize(ObjectDeserializer.java:218)
at co.elastic.clients.json.ObjectDeserializer.deserialize(ObjectDeserializer.java:148)
at co.elastic.clients.json.JsonpDeserializer.deserialize(JsonpDeserializer.java:77)
at co.elastic.clients.json.ObjectBuilderDeserializer.deserialize(ObjectBuilderDeserializer.java:79)
at co.elastic.clients.json.DelegatingDeserializer$SameType.deserialize(DelegatingDeserializer.java:43)
at co.elastic.clients.json.ObjectDeserializer$FieldObjectDeserializer.deserialize(ObjectDeserializer.java:78)
at co.elastic.clients.json.ObjectDeserializer.deserialize(ObjectDeserializer.java:192)
at co.elastic.clients.json.ObjectDeserializer.deserialize(ObjectDeserializer.java:148)
at co.elastic.clients.json.JsonpDeserializer.deserialize(JsonpDeserializer.java:77)
at co.elastic.clients.json.ObjectBuilderDeserializer.deserialize(ObjectBuilderDeserializer.java:79)
at co.elastic.clients.json.DelegatingDeserializer$SameType.deserialize(DelegatingDeserializer.java:43)
at co.elastic.clients.transport.ElasticsearchTransportBase.decodeTransportResponse(ElasticsearchTransportBase.java:340)
... 5 more
Caused by: jakarta.json.JsonException: Unable to get a JsonProvider. Check your classpath or thread context classloader.
at co.elastic.clients.json.JsonpUtils.findProvider(JsonpUtils.java:85)
at co.elastic.clients.json.JsonpUtils.provider(JsonpUtils.java:55)
at co.elastic.clients.json.jackson.JsonValueParser.(JsonValueParser.java:43)
at co.elastic.clients.json.jackson.JacksonJsonpParser.getValue(JacksonJsonpParser.java:242)
at co.elastic.clients.json.JsonpDeserializerBase$8.deserialize(JsonpDeserializerBase.java:254)
at co.elastic.clients.json.JsonpDeserializerBase$8.deserialize(JsonpDeserializerBase.java:248)
at co.elastic.clients.json.JsonpDeserializer.deserialize(JsonpDeserializer.java:77)
at co.elastic.clients.json.ObjectDeserializer$FieldObjectDeserializer.deserialize(ObjectDeserializer.java:78)
at co.elastic.clients.json.ObjectDeserializer.deserialize(ObjectDeserializer.java:192)
... 16 more
Caused by: jakarta.json.JsonException: Provider org.eclipse.parsson.JsonProviderImpl not found
at jakarta.json.spi.JsonProvider.newInstance(JsonProvider.java:160)
at jakarta.json.spi.JsonProvider.provider(JsonProvider.java:144)
at co.elastic.clients.json.JsonpUtils.findProvider(JsonpUtils.java:65)
... 24 more
Caused by: java.lang.ClassNotFoundException: org.eclipse.parsson.JsonProviderImpl
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:375)
at jakarta.json.spi.JsonProvider.newInstance(JsonProvider.java:157)
... 26 more
co.elastic.clients.transport.TransportException: node: https://xxx:9443/, status: 200, [es/search] Failed to decode response
at co.elastic.clients.transport.ElasticsearchTransportBase.decodeTransportResponse(ElasticsearchTransportBase.java:345)
at co.elastic.clients.transport.ElasticsearchTransportBase.getApiResponse(ElasticsearchTransportBase.java:304)
at co.elastic.clients.transport.ElasticsearchTransportBase.performRequest(ElasticsearchTransportBase.java:111)
at co.elastic.clients.elasticsearch.ElasticsearchClient.search(ElasticsearchClient.java:1887)
at co.elastic.clients.elasticsearch.ElasticsearchClient.search(ElasticsearchClient.java:1904)
at Main.main(Main.java:66)
Caused by: co.elastic.clients.json.JsonpMappingException: Error deserializing co.elastic.clients.elasticsearch._types.ShardStatistics: jakarta.json.JsonException: Unable to get a JsonProvider. Check your classpath or thread context classloader. (JSON path: _shards.total) (line no=1, column no=51, offset=-1)
at co.elastic.clients.json.JsonpMappingException.from0(JsonpMappingException.java:134)
at co.elastic.clients.json.JsonpMappingException.from(JsonpMappingException.java:121)
at co.elastic.clients.json.ObjectDeserializer.deserialize(ObjectDeserializer.java:218)
at co.elastic.clients.json.ObjectDeserializer.deserialize(ObjectDeserializer.java:148)
at co.elastic.clients.json.JsonpDeserializer.deserialize(JsonpDeserializer.java:77)
at co.elastic.clients.json.ObjectBuilderDeserializer.deserialize(ObjectBuilderDeserializer.java:79)
at co.elastic.clients.json.DelegatingDeserializer$SameType.deserialize(DelegatingDeserializer.java:43)
at co.elastic.clients.json.ObjectDeserializer$FieldObjectDeserializer.deserialize(ObjectDeserializer.java:78)
at co.elastic.clients.json.ObjectDeserializer.deserialize(ObjectDeserializer.java:192)
at co.elastic.clients.json.ObjectDeserializer.deserialize(ObjectDeserializer.java:148)
at co.elastic.clients.json.JsonpDeserializer.deserialize(JsonpDeserializer.java:77)
at co.elastic.clients.json.ObjectBuilderDeserializer.deserialize(ObjectBuilderDeserializer.java:79)
at co.elastic.clients.json.DelegatingDeserializer$SameType.deserialize(DelegatingDeserializer.java:43)
at co.elastic.clients.json.DelegatingDeserializer$SameType.deserialize(DelegatingDeserializer.java:43)
at co.elastic.clients.transport.endpoints.EndpointWithResponseMapperAttr$1.deserialize(EndpointWithResponseMapperAttr.java:56)
at co.elastic.clients.transport.ElasticsearchTransportBase.decodeTransportResponse(ElasticsearchTransportBase.java:340)
... 5 more
Caused by: jakarta.json.JsonException: Unable to get a JsonProvider. Check your classpath or thread context classloader.
at co.elastic.clients.json.JsonpUtils.findProvider(JsonpUtils.java:85)
at co.elastic.clients.json.JsonpUtils.provider(JsonpUtils.java:55)
at co.elastic.clients.json.jackson.JsonValueParser.(JsonValueParser.java:43)
at co.elastic.clients.json.jackson.JacksonJsonpParser.getValue(JacksonJsonpParser.java:242)
at co.elastic.clients.json.JsonpDeserializerBase$8.deserialize(JsonpDeserializerBase.java:254)
at co.elastic.clients.json.JsonpDeserializerBase$8.deserialize(JsonpDeserializerBase.java:248)
at co.elastic.clients.json.JsonpDeserializer.deserialize(JsonpDeserializer.java:77)
at co.elastic.clients.json.ObjectDeserializer$FieldObjectDeserializer.deserialize(ObjectDeserializer.java:78)
at co.elastic.clients.json.ObjectDeserializer.deserialize(ObjectDeserializer.java:192)
... 18 more
Caused by: jakarta.json.JsonException: Provider org.eclipse.parsson.JsonProviderImpl not found
at jakarta.json.spi.JsonProvider.newInstance(JsonProvider.java:160)
at jakarta.json.spi.JsonProvider.provider(JsonProvider.java:144)
at co.elastic.clients.json.JsonpUtils.findProvider(JsonpUtils.java:65)
... 26 more
Caused by: java.lang.ClassNotFoundException: org.eclipse.parsson.JsonProviderImpl
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:375)
at jakarta.json.spi.JsonProvider.newInstance(JsonProvider.java:157)
... 28 more

Are there any source code examples (perhaps on github) that uses mvn or gradle for Elastic Java Client library (perhaps I am missing the proper version of some library or so).

These are the libraries I am including:

  • /Users/romankagan/Downloads/commons-logging-1.2.jar
  • /Users/romankagan/Downloads/elasticsearch-java-8.9.0.jar
  • /Users/romankagan/Downloads/elasticsearch-rest-client-7.17.7.jar
  • /Users/romankagan/Downloads/httpasyncclient-4.1.5.jar
  • /Users/romankagan/Downloads/httpclient-4.5.14.jar
  • /Users/romankagan/Downloads/httpcore-4.4.12.jar
  • /Users/romankagan/Downloads/httpcore-nio-4.4.16.jar
  • /Users/romankagan/Downloads/jackson-annotations-2.15.2.jar
  • /Users/romankagan/Downloads/jackson-core-2.15.2.jar
  • /Users/romankagan/Downloads/jackson-databind-2.12.7.1.jar
  • /Users/romankagan/Downloads/jakarta.json-api-2.1.2.jar

I was able to solve the problem by using there libraries, I wish there would be some doco that outline exactly what libraries had to be included.

Here's the list:

  • commons-logging-1.2.jar
  • elasticsearch-java-8.9.0.jar
  • elasticsearch-rest-client-8.9.0.jar
  • httpasyncclient-4.1.5.jar
  • httpclient-4.5.14.jar
  • httpcore-4.4.13.jar
  • httpcore-nio-4.4.16.jar
  • jackson-annotations-2.15.2.jar
  • jackson-core-2.15.2.jar
  • jackson-databind-2.13.3.jar
  • jakarta.json-api-2.1.2.jar
  • jakarta.json.bind-api-2.0.0.jar
  • parsson-1.0.0.jar

Yes. And with a dependency manager you normally don't have to add manually your libs.

But that's a good point. @swallez do you think we can generate the dependency tree automatically and add this to the documentation?

mvn dependency:tree does a pretty good job.

There is a new PR I submitted, please check it out: Upgrade to 8.10.1 by kagan770 · Pull Request #76 · dadoonet/elasticsearch-java-client-demo · GitHub

1 Like

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