For the first error, my guess is that the server isn't returning properly formed JSON. Is there a proxy or gateway between your application and the Elasticsearch server that performs authentication? If authentication failed, that proxy may return data that the client doesn't understand.
For the second error with 7.17.12, this error means that a dependency in your classpath is causing the use of an older version of elasticsearch-rest-client. This should be fixed by adding the dependency as a top-level dependency in your project:
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-client</artifactId>
<version>7.17.12</version>
</dependency>