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