java.lang.instantiationerror org.elasticsearch.common.transport.transportaddress

  Kiến thức lập trình

I am using ElasticSearch 6 and trying to create client by using the following code

When i am trying to transport address getting error java.lang.instantiationerror org.elasticsearch.common.transport.transportaddress.

TransportClient client = new PreBuiltTransportClient(Settings.EMPTY)
        .addTransportAddress(new TransportAddress(InetAddress.getByName("host1"), 9300))
        .addTransportAddress(new TransportAddress(InetAddress.getByName("host2"), 9300));

I am creating this one jar and used the jar in another application

Any idea why we are getting java.lang.instantiationerror org.elasticsearch.common.transport.transportaddress

I had got the same error and it turned out the i was still pointing to older version of elastic search jars at runtime.
Therefor the problem should be solved by either
1. Using a fat jar
2. Setting correct elastic search jars in the classpath