You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
2.x client with Java 8 runtime and Apache HttpClient 5 Transport fails with java.lang.NoSuchMethodError: java.nio.ByteBuffer.flip()Ljava/nio/ByteBuffer
#904
Closed
peerkar opened this issue
Mar 26, 2024
· 0 comments
· Fixed by #920
When running the 2.9.1 client with Java 8 runtime and Apache HttpClient 5 Transport, I get the following exception when writing to the cluster:
java.lang.NoSuchMethodError: java.nio.ByteBuffer.flip()Ljava/nio/ByteBuffer;
at org.opensearch.client.transport.httpclient5.internal.HttpEntityAsyncEntityProducer.produce(HttpEntityAsyncEntityProducer.java:143)
at org.apache.hc.core5.http.nio.support.BasicRequestProducer.produce(BasicRequestProducer.java:104)
at org.apache.hc.client5.http.impl.async.InternalAbstractHttpAsyncClient$2.produce(InternalAbstractHttpAsyncClient.java:260)
at org.apache.hc.client5.http.impl.async.HttpAsyncMainClientExec$1.produce(HttpAsyncMainClientExec.java:163)
at org.apache.hc.core5.http.impl.nio.ClientHttp1StreamHandler.commitRequest(ClientHttp1StreamHandler.java:171)
at org.apache.hc.core5.http.impl.nio.ClientHttp1StreamHandler.lambda$produceOutput$0(ClientHttp1StreamHandler.java:183)
at org.apache.hc.client5.http.impl.async.HttpAsyncMainClientExec$1.produceRequest(HttpAsyncMainClientExec.java:150)
at org.apache.hc.core5.http.impl.nio.ClientHttp1StreamHandler.produceOutput(ClientHttp1StreamHandler.java:183)
at org.apache.hc.core5.http.impl.nio.ClientHttp1StreamDuplexer.execute(ClientHttp1StreamDuplexer.java:326)
at org.apache.hc.core5.http.impl.nio.AbstractHttp1StreamDuplexer.processCommands(AbstractHttp1StreamDuplexer.java:239)
at org.apache.hc.core5.http.impl.nio.AbstractHttp1StreamDuplexer.onOutput(AbstractHttp1StreamDuplexer.java:386)
at org.apache.hc.core5.http.impl.nio.AbstractHttp1IOEventHandler.outputReady(AbstractHttp1IOEventHandler.java:73)
at org.apache.hc.core5.http.impl.nio.ClientHttp1IOEventHandler.outputReady(ClientHttp1IOEventHandler.java:41)
at org.apache.hc.core5.reactor.InternalDataChannel.onIOEvent(InternalDataChannel.java:152)
at org.apache.hc.core5.reactor.InternalChannel.handleIOEvent(InternalChannel.java:51)
at org.apache.hc.core5.reactor.SingleCoreIOReactor.processEvents(SingleCoreIOReactor.java:178)
at org.apache.hc.core5.reactor.SingleCoreIOReactor.doExecute(SingleCoreIOReactor.java:127)
at org.apache.hc.core5.reactor.AbstractSingleCoreIOReactor.execute(AbstractSingleCoreIOReactor.java:86)
at org.apache.hc.core5.reactor.IOReactorWorker.run(IOReactorWorker.java:44)
at java.lang.Thread.run(Thread.java:750)
Steps to reproduce
Setup the OpenSearch server without security as described here
Run the following test program:
package com.example;
import org.apache.hc.core5.http.HttpHost;
import org.opensearch.client.opensearch.OpenSearchClient;
import org.opensearch.client.opensearch.indices.CreateIndexRequest;
import org.opensearch.client.opensearch.indices.OpenSearchIndicesClient;
import org.opensearch.client.transport.OpenSearchTransport;
import org.opensearch.client.transport.httpclient5.ApacheHttpClient5TransportBuilder;
public class ExampleClient {
public static void main(String[] args) {
final ApacheHttpClient5TransportBuilder builder = ApacheHttpClient5TransportBuilder.builder(
new HttpHost("http", "localhost", 9200));
OpenSearchTransport openSearchTransport = builder.build();
OpenSearchClient openSearchClient = new OpenSearchClient(openSearchTransport);
OpenSearchIndicesClient openSearchIndicesClient = openSearchClient.indices();
try {
openSearchIndicesClient.create(
CreateIndexRequest.of(
createIndexRequest->createIndexRequest.index("test_index")));
} catch (Exception exception) {
exception.printStackTrace();
}
}
}
Expected Results:
Index is created. No exceptions.
What is the bug?
When running the 2.9.1 client with Java 8 runtime and Apache HttpClient 5 Transport, I get the following exception when writing to the cluster:
Steps to reproduce
Setup the OpenSearch server without security as described here
Run the following test program:
Expected Results:
Index is created. No exceptions.
Actual Results:
An exception is thrown
Test environment
Possible Cause
Seems to be the same as described here
Changing this line
to
((Buffer) byteBuffer).flip();
and recompiling with JDK 11 seemed to fix the issue to me.
The text was updated successfully, but these errors were encountered: