0

I'm using Quarkus 2.16.6.Final with ElasticSearch 8.7. I've written a small piece of code to use ES's update_by_query feature.

try (Reader query = new StringReader(/*my json query String*/)) {
  var request = UpdateByQueryRequest.of(fn -> fn.index(index).withJson(query));

  return client.updateByQuery(request);
} catch (IOException e) {
  throw new RuntimeException(e);
}

And this is my ES client initialization code:

var credsProv = new BasicCredentialsProvider();

credsProv.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(username, password));

var restClient = RestClient.builder(HttpHost.create(host)).setHttpClientConfigCallback(
    hc -> hc.disableAuthCaching().setDefaultCredentialsProvider(credsProv)).build();

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

var client = new ElasticsearchAsyncClient(transport);

This actually works fine in normal jvm mode. However whenever I'm trying to run this is Quarkus Native(GraalVM) mode I'm getting this error:

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)
... 54 more
Caused by: java.lang.ClassNotFoundException: org.eclipse.parsson.JsonProviderImpl
    at [email protected]/java.lang.Class.forName(DynamicHub.java:1132)
    at [email protected]/java.lang.Class.forName(DynamicHub.java:1105)
    at jakarta.json.spi.JsonProvider.newInstance(JsonProvider.java:157)

As per the documentation, I've added required dependency in the Maven pom.

    <dependency>
        <groupId>co.elastic.clients</groupId>
        <artifactId>elasticsearch-java</artifactId>
        <version>8.7.0</version>
        <exclusions>
            <exclusion>
                <groupId>commons-logging</groupId>
                <artifactId>commons-logging</artifactId>
            </exclusion>
            <exclusion>
                <groupId>jakarta.json</groupId>
                <artifactId>jakarta.json-api</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.eclipse.parsson</groupId>
                <artifactId>parsson</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>jakarta.json</groupId>
        <artifactId>jakarta.json-api</artifactId>
        <version>2.1.1</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.eclipse.parsson</groupId>
        <artifactId>parsson</artifactId>
        <version>1.1.1</version>
        <scope>compile</scope>
    </dependency>

But that didn't solve this issue and wondering how come the same thing works on normal JVM but not in native mode in GraalVM

1 Answer 1

0

I had a similar problem which I resolved by replacing the JSON-P API and provider dependencies which I was using:

<dependency>
    <groupId>jakarta.json</groupId>
    <artifactId>jakarta.json-api</artifactId>
    <version>2.1.2</version>
</dependency>
<dependency>
    <groupId>org.eclipse</groupId>
    <artifactId>yasson</artifactId>
    <version>3.0.3</version>
</dependency>

with this Quarkus dependency:

<dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-jsonp</artifactId>
</dependency>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.