NoClassDefFoundError HttpAsyncResponseConsumer


(Sharat Jagannath) #1

getting following error
java.lang.NoClassDefFoundError: org/apache/http/nio/protocol/HttpAsyncResponseConsumer
for code-
RestClientImpl impl=new RestClientImpl();
impl.restClient= RestClient.builder( new HttpHost("localhost", 9200)).build();

imported these two-
import org.apache.http.HttpHost;
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;

using ES v5 rest api jar.


(Nik Everett) #2

I believe this is the same problem as

You can work around it by adding the http client's dependencies to your POM. In gradle they look like:

  compile "org.apache.httpcomponents:httpclient:4.5.2"
  compile "org.apache.httpcomponents:httpcore:4.4.5"
  compile "org.apache.httpcomponents:httpasyncclient:4.1.2"
  compile "org.apache.httpcomponents:httpcore-nio:4.4.5"
  compile "commons-codec:commons-codec:1.10"
  compile "commons-logging:commons-logging:1.1.3"

I won't try to translate that to maven because I can't test it locally at this point but it should be fairly trivial. I'll update the issue I linked above to make it clear that this is also happening for the http client.


(Nik Everett) #3

Actually the pom looks right to me. How are you attempting to resolve the transitive dependencies?


(Sharat Jagannath) #4

resolved it. There was some issue with my eclipse.


(system) #5