# Elasticsearch 5 Java client does not work with Groovy Grape

**URL:** <https://discuss.elastic.co/t/elasticsearch-5-java-client-does-not-work-with-groovy-grape/64267>\
**Category:** Elasticsearch\
**Created:** [October 28, 2016, 9:09am UTC](https://discuss.elastic.co/t/elasticsearch-5-java-client-does-not-work-with-groovy-grape/64267 "2016-10-28T09:09:58Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fabrizio\_Fortino](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fabrizio_fortino/32/1719_2.png) [@Fabrizio\_Fortino](https://discuss.elastic.co/u/Fabrizio_Fortino)\
**Post date:** [October 28, 2016, 9:09am UTC](https://discuss.elastic.co/t/elasticsearch-5-java-client-does-not-work-with-groovy-grape/64267/1 "2016-10-28T09:09:58Z")

</div>

Not sure this problem is caused by Elasticsearch or Groovy Grape.

I have a groovy script that uses Grape to handle dependencies:

```
@Grapes([
        @Grab(group = 'org.elasticsearch', module = 'elasticsearch', version = '5.0.0'),
        @Grab(group = 'org.elasticsearch.client', module = 'transport', version = '5.0.0'),
        @Grab(group = 'org.apache.logging.log4j', module = 'log4j-api', version = '2.7'),
        @Grab(group = 'org.apache.logging.log4j', module = 'log4j-core', version = '2.7')
])

```

Netty transitive dependencies coming from 'org.elasticsearch.client.transport' are not correctly included and when I try to connect I get the following ClassNotFoundException

```
Caught: java.lang.NoClassDefFoundError: io/netty/channel/RecvByteBufAllocator
java.lang.NoClassDefFoundError: io/netty/channel/RecvByteBufAllocator
        at org.elasticsearch.transport.Netty4Plugin.getSettings(Netty4Plugin.java:39)
        at org.elasticsearch.plugins.PluginsService.lambda$getPluginSettings$0(PluginsService.java:85)
        at org.elasticsearch.plugins.PluginsService.getPluginSettings(PluginsService.java:85)
        at org.elasticsearch.client.transport.TransportClient.buildTemplate(TransportClient.java:115)
        at org.elasticsearch.client.transport.TransportClient.<init>(TransportClient.java:228)
        at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:69)
        at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:65)

```

Running 'grape resolve org.elasticsearch.client transport 5.0.0' returns

```
/Users/user/.groovy/grapes/org.elasticsearch.client/transport/jars/transport-5.0.0.jar
/Users/user/.groovy/grapes/org.elasticsearch/elasticsearch/jars/elasticsearch-5.0.0.jar
/Users/user/.groovy/grapes/org.apache.lucene/lucene-core/jars/lucene-core-6.2.0.jar
/Users/user/.groovy/grapes/org.elasticsearch/securesm/jars/securesm-1.1.jar
/Users/user/.groovy/grapes/net.sf.jopt-simple/jopt-simple/jars/jopt-simple-5.0.2.jar
/Users/user/.groovy/grapes/com.carrotsearch/hppc/jars/hppc-0.7.1.jar
/Users/user/.groovy/grapes/joda-time/joda-time/jars/joda-time-2.9.4.jar
/Users/user/.groovy/grapes/org.joda/joda-convert/jars/joda-convert-1.2.jar
/Users/user/.groovy/grapes/org.yaml/snakeyaml/bundles/snakeyaml-1.15.jar
/Users/user/.groovy/grapes/com.fasterxml.jackson.core/jackson-core/bundles/jackson-core-2.8.1.jar
/Users/user/.groovy/grapes/com.tdunning/t-digest/jars/t-digest-3.0.jar
/Users/user/.groovy/grapes/org.hdrhistogram/HdrHistogram/bundles/HdrHistogram-2.1.6.jar
/Users/user/.groovy/grapes/net.java.dev.jna/jna/jars/jna-4.2.2.jar
/Users/user/.groovy/grapes/org.elasticsearch.plugin/transport-netty3-client/jars/transport-netty3-client-5.0.0.jar
/Users/user/.groovy/grapes/io.netty/netty/bundles/netty-3.10.6.Final.jar
/Users/user/.groovy/grapes/org.elasticsearch.plugin/transport-netty4-client/jars/transport-netty4-client-5.0.0.jar
/Users/user/.groovy/grapes/io.netty/netty-common/jars/netty-common-4.1.5.Final.jar
/Users/user/.groovy/grapes/org.elasticsearch.plugin/reindex-client/jars/reindex-client-5.0.0.jar
/Users/user/.groovy/grapes/org.elasticsearch.client/rest/jars/rest-5.0.0.jar
/Users/user/.groovy/grapes/org.apache.httpcomponents/httpcore/jars/httpcore-4.4.5.jar
/Users/user/.groovy/grapes/commons-codec/commons-codec/jars/commons-codec-1.10.jar
/Users/user/.groovy/grapes/commons-logging/commons-logging/jars/commons-logging-1.1.3.jar
/Users/user/.groovy/grapes/org.elasticsearch.plugin/lang-mustache-client/jars/lang-mustache-client-5.0.0.jar
/Users/user/.groovy/grapes/com.github.spullara.mustache.java/compiler/jars/compiler-0.9.3.jar
/Users/user/.groovy/grapes/org.elasticsearch.plugin/percolator-client/jars/percolator-client-5.0.0.jar

```

I have also tried to include the netty dependency but it then complains about other missing ones (like lucene).  
The same script with elasticsearch 2.4.x works well and the dependency are correctly resolved. Any idea?

---

<div class="post-metadata">

**Author:** ![ywelsch](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ywelsch/32/7751_2.png) [@ywelsch](https://discuss.elastic.co/u/ywelsch)\
**Post date:** [October 28, 2016, 10:14am UTC](https://discuss.elastic.co/t/elasticsearch-5-java-client-does-not-work-with-groovy-grape/64267/2 "2016-10-28T10:14:34Z")

</div>

I'm not sure what the exact problem is. I just noticed that grape resolves some of the dependencies in a funky way depending on the mode used, e.g.:

```auto
$ grape resolve org.elasticsearch.plugin transport-netty4-client 5.0.0
/Users/ywelsch/.groovy/grapes/org.elasticsearch.plugin/transport-netty4-client/jars/transport-netty4-client-5.0.0.jar
/Users/ywelsch/.groovy/grapes/io.netty/netty-common/jars/netty-common-4.1.5.Final.jar

```

```auto
$ grape resolve -ant org.elasticsearch.plugin transport-netty4-client 5.0.0
<pathelement location="/Users/ywelsch/.groovy/grapes/org.elasticsearch.plugin/transport-netty4-client/jars/transport-netty4-client-5.0.0.jar">
<pathelement location="/Users/ywelsch/.groovy/grapes/io.netty/netty-common/jars/netty-common-4.1.5.Final.jar">

```

```auto
$ grape resolve -ivy org.elasticsearch.plugin transport-netty4-client 5.0.0
<dependency org="org.elasticsearch.plugin" name="transport-netty4-client" revision="5.0.0">
<dependency org="io.netty" name="netty-buffer" revision="4.1.5.Final">
<dependency org="io.netty" name="netty-codec" revision="4.1.5.Final">
<dependency org="io.netty" name="netty-codec-http" revision="4.1.5.Final">
<dependency org="io.netty" name="netty-common" revision="4.1.5.Final">
<dependency org="io.netty" name="netty-handler" revision="4.1.5.Final">
<dependency org="io.netty" name="netty-resolver" revision="4.1.5.Final">
<dependency org="io.netty" name="netty-transport" revision="4.1.5.Final">

```

---

<div class="post-metadata">

**Author:** ![Fabrizio\_Fortino](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fabrizio_fortino/32/1719_2.png) [@Fabrizio\_Fortino](https://discuss.elastic.co/u/Fabrizio_Fortino)\
**Post date:** [October 28, 2016, 10:54am UTC](https://discuss.elastic.co/t/elasticsearch-5-java-client-does-not-work-with-groovy-grape/64267/3 "2016-10-28T10:54:12Z")

</div>

Thanks for that!

It seems that grapes resolves OK when -ivy is passed as argument. I do think something has changed in version 5 since it was working fine in 2.4 .

Do you know if I can change the resolver to ivy in my groovy script? I have seen there is a GrabResolver but I am not sure is the right way to sort the problem out.

ty

---

<div class="post-metadata">

**Author:** ![ywelsch](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ywelsch/32/7751_2.png) [@ywelsch](https://discuss.elastic.co/u/ywelsch)\
**Post date:** [October 28, 2016, 1:10pm UTC](https://discuss.elastic.co/t/elasticsearch-5-java-client-does-not-work-with-groovy-grape/64267/4 "2016-10-28T13:10:33Z")

</div>

I've investigated further and opened

> <https://github.com/elastic/elasticsearch/issues/21170>

---

<div class="post-metadata">

**Author:** ![jasontedor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasontedor/32/66992_2.png) [@jasontedor](https://discuss.elastic.co/u/jasontedor)\
**Post date:** [November 4, 2016, 12:23pm UTC](https://discuss.elastic.co/t/elasticsearch-5-java-client-does-not-work-with-groovy-grape/64267/5 "2016-11-04T12:23:18Z")

</div>

Side note: the version of the Log4j dependency for 5.0.0 should be 2.6.2, not 2.7 as you have here. Otherwise you will see `NoClassDefFoundError` for `org.apache.logging.log4j.core.async.DaemonThreadFactory`.

---

<div class="post-metadata">

**Author:** ![Fabrizio\_Fortino](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fabrizio_fortino/32/1719_2.png) [@Fabrizio\_Fortino](https://discuss.elastic.co/u/Fabrizio_Fortino)\
**Post date:** [November 16, 2016, 12:21pm UTC](https://discuss.elastic.co/t/elasticsearch-5-java-client-does-not-work-with-groovy-grape/64267/6 "2016-11-16T12:21:19Z")

</div>

Solved with ES 5.0.1

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 10:05pm UTC](https://discuss.elastic.co/t/elasticsearch-5-java-client-does-not-work-with-groovy-grape/64267/7 "2017-07-05T22:05:41Z")

</div>


