Luuk01
(Luuk Daemen)
January 10, 2016, 6:12pm
1
How to create a TranspotClient in 2.1.x?
I recently updated to elastic search 2.1.x.
Iam suffering to create a TransportClient via the JAVA API.
My Code looks like
** Settings settings = Settings.settingsBuilder()**
** .put("cluster.name ", "tst-found2day").build();**
** Client client = TransportClient.builder().settings(settings).build().addTransportAddress(new InetSocketTransportAddress(new InetSocketAddress("localhost", 9300)));**
When i run this, i got the following error:
java.lang.NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.directExecutor()Ljava/util/concurrent/Executor;
** at org.elasticsearch.threadpool.ThreadPool.(ThreadPool.java:190)**
** at org.elasticsearch.client.transport.TransportClient$Builder.build(TransportClient.java:130)**
What am i doing wrong ?
Thanks,
Luuk
jprante
(Jörg Prante)
January 10, 2016, 6:30pm
2
What Google Guava version is in your classpath?
Luuk01
(Luuk Daemen)
January 10, 2016, 8:00pm
4
I am using Gradle to build the project.
I have installed kibana and the sense plugin.
In can index via Sense, but unable to connect via java client.
Luuk
jprante
(Jörg Prante)
January 10, 2016, 8:08pm
5
Please recheck. You have an older version of Guava in your project and this is causing the runtime error.
jprante
(Jörg Prante)
January 10, 2016, 8:25pm
7
No, version 18 is correct.
Check your classpath at runtime, your program fails because your Guava is older than version 18.
Luuk01
(Luuk Daemen)
January 11, 2016, 10:55am
8
I found the following entry on my classpath
.sdkman/grails/2.5.0/lib/com.google.guava/guava/jars/guava-10.0.1 .jar
before entry :
Users/luukdaemen/.m2/repository/com/google/guava/guava/18.0/guava-18.0.jar
This is probably causing it.
How can i exclude the old library from the class path, related to the build.groovy ?
jprante
(Jörg Prante)
January 11, 2016, 12:06pm
9
If Grails could use Guava 18, then it would work. But it can't. This is more a less a Grails question.
Read the docs how to shade jars
https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/_dealing_with_jar_dependency_conflicts.html
Luuk01
(Luuk Daemen)
January 11, 2016, 12:35pm
10
Well, i managed to exclude the Guava 10.0.1.jar from my class path.
First by renaming the file directly in the sdkman folder.
This was just to show that the right jar was pcked up.
It worked.
i renamed the file back to .jar afterwards, because it is not a prober solution.
Secondly, within Intellj, i was able to remove the 10.0.1 jar from the External Libraries section within the project structure.
This causes that the 10.0.1 jar will be excluded from the class path.
Building the war file within Intellj, also excludes this jar.
So far,
Luuk