The [0.0.0] version of the [jdbc] client is not compatible with Elasticsearch version [7.10.0];]

Hello, everyone, I have a strange problem with the JDBC driver version after packaging.

<dependency>
    <groupId>org.elasticsearch.plugin</groupId>
    <artifactId>x-pack-sql-jdbc</artifactId>
    <version>7.10.0</version>
</dependency>

When I run my code in IDEA to access elasticsearch, it works normally.

Next, I execute mvn package to get a jar with dependencies.
When I run this jar to access elasticsearch, the error is as follows:

java.sql.SQLException: Server sent bad type [action_request_validation_exception]. Original type was [Validation Failed: 1: The [0.0.0] version of the [jdbc] client is not compatible with Elasticsearch version [7.10.0];]. [org.elasticsearch.action.ActionRequestValidationException: Validation Failed: 1: The [0.0.0] version of the [jdbc] client is not compatible with Elasticsearch version [7.10.0];
        at org.elasticsearch.action.ValidateActions.addValidationError(ValidateActions.java:26)
        at org.elasticsearch.xpack.sql.action.AbstractSqlQueryRequest.validate(AbstractSqlQueryRequest.java:239)
        at org.elasticsearch.xpack.sql.action.SqlQueryRequest.validate(SqlQueryRequest.java:79)
        at org.elasticsearch.action.support.TransportAction.execute(TransportAction.java:144)
        at org.elasticsearch.action.support.TransportAction.execute(TransportAction.java:83)
        at org.elasticsearch.client.node.NodeClient.executeLocally(NodeClient.java:86)
        at org.elasticsearch.client.node.NodeClient.doExecute(NodeClient.java:75)
        at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:412)
        at org.elasticsearch.xpack.sql.plugin.RestSqlQueryAction.lambda$prepareRequest$0(RestSqlQueryAction.java:116)
        at org.elasticsearch.rest.BaseRestHandler.handleRequest(BaseRestHandler.java:115)
        at org.elasticsearch.xpack.security.rest.SecurityRestFilter.handleRequest(SecurityRestFilter.java:88)
        at org.elasticsearch.rest.RestController.dispatchRequest(RestController.java:258)
        at org.elasticsearch.rest.RestController.tryAllHandlers(RestController.java:340)
        at org.elasticsearch.rest.RestController.dispatchRequest(RestController.java:191)
        at org.elasticsearch.http.AbstractHttpServerTransport.dispatchRequest(AbstractHttpServerTransport.java:319)
        at org.elasticsearch.http.AbstractHttpServerTransport.handleIncomingRequest(AbstractHttpServerTransport.java:384)
......

I guess that there was a problem with the version metadata when packaging, but I didn't found a solution.

Otherwise, I found some source code of Elasticsearch that may be useful.

elasticsearch/ClientVersion.java at master · elastic/elasticsearch · GitHub

According to elasticsearch/ClientVersion.java at master · elastic/elasticsearch · GitHub

I add the following configuration to pom.xml, and the issue is solved.

<manifestEntries>
    <X-Compile-Elasticsearch-Version>7.10.0</X-Compile-Elasticsearch-Version>
</manifestEntries>

Hi @yxmm-wxe,

Glad that it eventually works for you now.

Just in case, if you download the driver manually and unzip it you can see that the X-Compile-Elasticsearch-Version is already there. So I imagine that for some reason rather the manifest can't be read in your setup.
Feel free to provide some more details about how it's being run, if you want to pursuit it further, but if you're already happy with your fix, then all good.

Thank you for your answer.

My issue is because the Elasticsearch jdbc driver is packaged to my final jar, and the MANIFEST.MF is missing.
As you know, the X-Compile-Elasticsearch-Version is defined in MANIFEST.MF.

Finally, I choose to load the driver dynamically. And my previous solution was not reasonable.

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