Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):
Java 8
Opensearch 2.4.0
Describe the issue :
I’m unable to connect to my OpenSearch cluster due to versions compatibilities. I think this is because OpenSearch 2.0 does not have support for Java 8 but what is the alternative.
How do I connect my java 8 application to OpenSearch
Configuration :
public OpenSearchClient getClient() {
SdkHttpClient httpClient = ApacheHttpClient.builder().build();
return new OpenSearchClient(
new AwsSdk2Transport(
httpClient,
host,
“es”,
Region.of(region),
AwsSdk2TransportOptions.builder().build()
)
);
}
This does not compile
Is there any way you can run this in a higher version of java?
Here’s the status on java 8 support in opensearch-java:
opened 02:18PM - 04 May 22 UTC
## What kind of business use case are you trying to solve? What are your require… ments?
Many users still need Java 8 for their clients for maximum Java compatibility.
**What is the problem? What is preventing you from meeting the requirements?**
With the introduction of OpenSearch 2.0.0, the OpenSearch 2.0.0 build has updated to Java 11. This also includes the `opensearch-rest-client` and `opensearch-rest-high-level-client` clients.
Users of clients who wish to update their client version must now update to Java 11.
Additionally, the opensearch-java client relies on the `opensearch-rest-client`. Per opensearch-project/opensearch-clients#17, this is the client which is meant to have the most compatibility.
Here is an example of updating Data Prepper (which currently supports Java 8):
```
> No matching variant of org.opensearch.client:opensearch-rest-high-level-client:2.0.0-rc1 was found. The consumer was configured to find a runtime of a library compatible with Java 8, packaged as a jar, and its dependencies declared externally but:
- Variant 'apiElements' capability org.opensearch.client:opensearch-rest-high-level-client:2.0.0-rc1 declares a library, packaged as a jar, and its dependencies declared externally:
- Incompatible because this component declares an API of a component compatible with Java 11 and the consumer needed a runtime of a component compatible with Java 8
- Variant 'runtimeElements' capability org.opensearch.client:opensearch-rest-high-level-client:2.0.0-rc1 declares a runtime of a library, packaged as a jar, and its dependencies declared externally:
- Incompatible because this component declares a component compatible with Java 11 and the consumer needed a component compatible with Java 8
```
**What are you proposing? What do you suggest we do to solve the problem or improve the existing situation?**
I propose that the OpenSearch Core's `opensearch-rest-client` and `opensearch-rest-high-level-client` projects be made to use Java 8. The Gradle build can setup the `sourceCompatibility` and `targetCompatibility` to ensure that it uses only Java 8 language features.
An alternative solution would be to remove the dependency that `opensearch-java` has on `opensearch-rest-client`.
**What are your assumptions or prerequisites?**
None.
**What are remaining open questions?**
Can Gradle toolchains or another mechanism help ensure that the client projects do not use any Java 11 APIs?
Feel free to participate or comment in that issue.
system
Closed
August 27, 2023, 8:09pm
3
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.