Java elasticsearch client is always null

I recently made the switch from elasticsearch 1.7 to 2.0, and I noticed how you changed the client setting. I looked through the documentation and for some reason the client is always null. I was wondering if I configured it correctly.

Here is my code:

Client client = null; try { client = TransportClient.builder().build().addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300)); } catch (Exception e) { Logger.log(e); } finally { client.close(); try { conn.close(); } catch (SQLException e) { Logger.log(e); } } 
+8
java elasticsearch
source share
1 answer

As noted in the comments, but in a bit more detail: Elasticsearch 2.0 uses Guava 18.0 (see https://github.com/elastic/elasticsearch/pull/7593 ). Therefore, to fix errors such as java.lang.NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.directExecutor()Ljava/util/concu‌rrent/Executor; , be sure to use Guava 18.0 as a dependency, not other versions.

+14
source share

All Articles