3

I am migrating from OpenSearch Java High Level REST Client v.2.2.1 to Java Client v.2.2.1.

The logic that I am rewriting builds filters values by concurrently issuing search aggregation requests to OpenSearch. For instance, filter Organization Name with values OrgA, OrgB,...., OrgN or filter Deadline Date with values 2022-01-02, 2022-02-10,....:

filters.parallelStream().forEach(filter -> {
            List<Object> values = openSearchService.getFilterValues(//method parameters);
            filter.setValues(values);
        });

After switching to OpenSearch Java client, I start getting following ClassCastException exception:

CAUSE [java.lang.ClassCastException: class org.glassfish.json.JsonProviderImpl cannot be cast to class jakarta.json.spi.JsonProvider (org.glassfish.json.JsonProviderImpl is in unnamed module of loader 'org.glassfish.jakarta.json@1.1.6' @1a8a8f7c; jakarta.json.spi.JsonProvider is in unnamed module of loader 'deployment.my-app.war' @4543f974)]

Client config:

@Bean
public OpenSearchClient openSearchClient() {
    RestClient restClient = RestClient.builder(new HttpHost(openSearchHost, openSearchPort, "http")).build();
    OpenSearchTransport transport = new RestClientTransport(restClient, new JacksonJsonpMapper());
    return new OpenSearchClient(transport);
}

Note: the fault is gone if I switch to sequential stream instead of parallel, which confuses me.

Question: is something wrong with the client configuration?

App Details: Spring based v 5.3.19, the war file is deployed to WildFly v.26.1.0.Final.

Also, I tried add explicit jakarta.json dependency as suggested here, but that does not help.

Hutsul
  • 1,535
  • 4
  • 31
  • 51

0 Answers0