Java Client Connect

Versions 3.4.0:

Describe the issue: Unable to create a Client connection. I’ve tried RestClient, RestHighLevelClient and the Http 5 client. I get the same error with all types. I can connect and retrieve information using postman and HttpClient in java code for both https and http

Configuration: Use Docker compose to install and run the server. I have toggled between https and http with no luck. OpenSearch seems to be working correctly. Not getting any messages in the log in the docker container

Relevant Logs or Screenshots: I get the following stack trace
Exception in thread “httpclient-dispatch-1” java.lang.NoSuchMethodError: ‘void org.apache.hc.core5.http2.impl.nio.ClientH2UpgradeHandler.(org.apache.hc.core5.http2.impl.nio.ClientH2StreamMultiplexerFactory)’

at org.apache.hc.client5.http.impl.async.HttpAsyncClientProtocolNegotiationStarter.createHandler(HttpAsyncClientProtocolNegotiationStarter.java:260)

at org.apache.hc.core5.reactor.InternalConnectChannel.onIOEvent(InternalConnectChannel.java:77)

at org.apache.hc.core5.reactor.InternalChannel.handleIOEvent(InternalChannel.java:51)

at org.apache.hc.core5.reactor.SingleCoreIOReactor.processEvents(SingleCoreIOReactor.java:176)

at org.apache.hc.core5.reactor.SingleCoreIOReactor.doExecute(SingleCoreIOReactor.java:125)

at org.apache.hc.core5.reactor.AbstractSingleCoreIOReactor.execute(AbstractSingleCoreIOReactor.java:92)

at org.apache.hc.core5.reactor.IOReactorWorker.run(IOReactorWorker.java:44)

at java.base/java.lang.Thread.run(Thread.java:1583)

Hi @etewa ,

It looks like you have dependencies conflict / misalignment, the opensearch-java client depends on Apache HttpClient 5.5 / Apache HttpCore 5.3.4. Could you please share the dependency tree or project configuration?

Thank you.

Thanks for the assistance, I really appreciate it! I’m using Gradle. Here are the dependencies:

dependencies {

// Spring stuff

implementation 'org.apache.velocity:velocity-engine-core:2.4.1'

implementation 'org.springframework.boot:spring-boot-starter-web'

implementation 'org.springframework.boot:spring-boot-starter-validation'

implementation 'org.springframework.boot:spring-boot-starter-data-jpa'

implementation 'org.springframework.boot:spring-boot-starter-pulsar'

providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'

implementation 'org.springframework.boot:spring-boot-starter-actuator'

developmentOnly 'org.springframework.boot:spring-boot-devtools'

runtimeOnly 'org.postgresql:postgresql:42.7.3'

// JSON Parser

implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.18.3'

// Testing

testRuntimeOnly 'org.junit.platform:junit-platform-launcher'

testImplementation('org.springframework.boot:spring-boot-starter-test'){

	exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'

}

testImplementation 'org.springframework.security:spring-security-test'

testImplementation 'org.mockito:mockito-inline:5.2.0'

//OpenAPI3 (Swagger)

implementation 'org.springdoc:springdoc-openapi-ui:1.8.0'

/\*\* Start 3rd Party Libs \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/

implementation 'org.localbeat:localbeat-lib:+'

implementation 'org.localbeat:localbeat-entity:+'

implementation 'org.apache.commons:commons-lang3:3.18.0'

implementation("commons-io:commons-io:2.21.0")

implementation 'commons-codec:commons-codec:1.18.0'

implementation("org.bouncycastle:bcprov-jdk15on:1.70")

// Open Search

implementation 'org.opensearch.client:opensearch-rest-client:3.4.0'

implementation 'org.opensearch.client:opensearch-java:3.0.0'

implementation 'org.apache.httpcomponents.client5:httpclient5:5.2.1'

implementation("org.opensearch.client:opensearch-rest-high-level-client:3.4.0")

implementation("org.apache.httpcomponents.core5:httpcore5:5.3.4")

}

Please align with the versions from above (httpclient5 is 5.2.1, it will not work)

Thank You! That worked