# Playing with GroovyConsole

**URL:** <https://discuss.elastic.co/t/playing-with-groovyconsole/3900>\
**Category:** Elasticsearch\
**Created:** [February 8, 2011, 4:43pm UTC](https://discuss.elastic.co/t/playing-with-groovyconsole/3900 "2011-02-08T16:43:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Hernandez](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/david_hernandez/32/3270_2.png) [@David\_Hernandez](https://discuss.elastic.co/u/David_Hernandez)\
**Post date:** [February 8, 2011, 4:43pm UTC](https://discuss.elastic.co/t/playing-with-groovyconsole/3900/1 "2011-02-08T16:43:59Z")

</div>

Hi I'm playing with the Groovy API inside Groovy Console

@GrabResolver(name='elasticsearch',  
root='[http://oss.sonatype.org/content/repositories/releases/](http://oss.sonatype.org/content/repositories/releases/)')  
@GrabResolver(name='maven', root='[http://repo1.maven.org/maven2/](http://repo1.maven.org/maven2/)')  
@Grab('org.elasticsearch:elasticsearch-client-groovy:0.10.0')  
import org.elasticsearch.groovy.client.GClient  
import org.elasticsearch.groovy.node.GNode  
import org.elasticsearch.groovy.node.GNodeBuilder  
import static org.elasticsearch.groovy.node.GNodeBuilder.\*

GNodeBuilder nodeBuilder = nodeBuilder();  
nodeBuilder.settings {  
node {  
client = true  
}  
cluster {  
name = "elasticsearch"  
}  
}

GNode node = nodeBuilder.node()  
node.stop().close()

I'm getting always this exception about configuration of names.txt :S

org.elasticsearch.env.FailedToResolveConfigException: Failed to  
resolve config path [names.txt], tried file path [names.txt], path  
file [C:\develop\Groovy-1.7.6\bin\config\names.txt], and classpath

```
at org.elasticsearch.env.Environment.resolveConfig(Environment.java:163)

```

I have running a node in localhost

curl -XGET '[http://localhost:9200/\_cluster/health](http://localhost:9200/_cluster/health)'  
{"cluster\_name":"elasticsearch","status":"yellow","timed\_out":false,"number\_of\_nodes":1,"number\_of\_data\_nodes":1,"active\_primary\_shards":5,"active\_shards"  
:5,"relocating\_shards":0,"initializing\_shards":0,"unassigned\_shards":5}  
hernand@UKLON-05916 ~/tomcat/bin

$ curl -XGET '[http://localhost:9200/](http://localhost:9200/)'  
{  
"ok" : true,  
"name" : "Solitaire",  
"version" : {  
"number" : "0.14.4",  
"date" : "2011-01-31T21:37:39",  
"snapshot\_build" : false  
},  
.....

Any ideas what happend?

Regards  
David H

---

<div class="post-metadata">

**Author:** ![Enrique\_Medina\_Monte](https://avatars.discourse-cdn.com/v4/letter/e/4491bb/32.png) [@Enrique\_Medina\_Monte](https://discuss.elastic.co/u/Enrique_Medina_Monte)\
**Post date:** [February 8, 2011, 4:50pm UTC](https://discuss.elastic.co/t/playing-with-groovyconsole/3900/2 "2011-02-08T16:50:33Z")

</div>

Hi David,

Try this out. It worked for me:

> <https://gist.github.com/emedina/816732>

Regards.

On Tue, Feb 8, 2011 at 5:43 PM, David Hernández [dahernan@gmail.com](mailto:dahernan@gmail.com) wrote:

> Hi I'm playing with the Groovy API inside Groovy Console
> 
> @GrabResolver(name='elasticsearch',  
> root='[Central Repository:](http://oss.sonatype.org/content/repositories/releases/)')  
> @GrabResolver(name='maven', root='[http://repo1.maven.org/maven2/](http://repo1.maven.org/maven2/)')  
> @Grab('org.elasticsearch:elasticsearch-client-groovy:0.10.0')  
> import org.elasticsearch.groovy.client.GClient  
> import org.elasticsearch.groovy.node.GNode  
> import org.elasticsearch.groovy.node.GNodeBuilder  
> import static org.elasticsearch.groovy.node.GNodeBuilder.\*
> 
> GNodeBuilder nodeBuilder = nodeBuilder();  
> nodeBuilder.settings {  
> node {  
> client = true  
> }  
> cluster {  
> name = "elasticsearch"  
> }  
> }
> 
> GNode node = nodeBuilder.node()  
> node.stop().close()
> 
> I'm getting always this exception about configuration of names.txt :S
> 
> org.elasticsearch.env.FailedToResolveConfigException: Failed to  
> resolve config path [names.txt], tried file path [names.txt], path  
> file [C:\develop\Groovy-1.7.6\bin\config\names.txt], and classpath
> 
> ```
> at
> 
> ```
> 
> org.elasticsearch.env.Environment.resolveConfig(Environment.java:163)
> 
> I have running a node in localhost
> 
> curl -XGET '[http://localhost:9200/\_cluster/health](http://localhost:9200/_cluster/health)'
> 
> {"cluster\_name":"elasticsearch","status":"yellow","timed\_out":false,"number\_of\_nodes":1,"number\_of\_data\_nodes":1,"active\_primary\_shards":5,"active\_shards"  
> :5,"relocating\_shards":0,"initializing\_shards":0,"unassigned\_shards":5}  
> hernand@UKLON-05916 ~/tomcat/bin
> 
> $ curl -XGET '[http://localhost:9200/](http://localhost:9200/)'  
> {  
> "ok" : true,  
> "name" : "Solitaire",  
> "version" : {  
> "number" : "0.14.4",  
> "date" : "2011-01-31T21:37:39",  
> "snapshot\_build" : false  
> },  
> .....
> 
> Any ideas what happend?
> 
> Regards  
> David H

---

<div class="post-metadata">

**Author:** ![David\_Hernandez](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/david_hernandez/32/3270_2.png) [@David\_Hernandez](https://discuss.elastic.co/u/David_Hernandez)\
**Post date:** [February 8, 2011, 5:19pm UTC](https://discuss.elastic.co/t/playing-with-groovyconsole/3900/3 "2011-02-08T17:19:41Z")

</div>

I'm afraid it doesn't ☹

groovy\> @GrabResolver(name='Codehaus', root='[http://repository.codehaus.org](http://repository.codehaus.org)')  
groovy\> @GrabResolver(name='Codehaus.Snapshots',  
root='[http://snapshots.repository.codehaus.org](http://snapshots.repository.codehaus.org)')  
groovy\> @GrabResolver(name='Codehaus.Snapshots',  
root='[Central Repository:](http://oss.sonatype.org/content/repositories/releases/)')  
groovy\> @GrabResolver(name='Codehaus.Snapshots',  
root='[http://repo1.maven.org/maven2/](http://repo1.maven.org/maven2/)')  
groovy\> @Grapes([  
groovy\> @Grab(group='org.codehaus.groovy.modules.http-builder',  
module='http-builder', version='0.5.1'),  
groovy\> @Grab(group='org.elasticsearch',  
module='elasticsearch-client-groovy', version='0.10.0'),  
groovy\> @Grab(group='org.elasticsearch',  
module='elasticsearch-lang-groovy', version='0.14.3'),  
groovy\> @Grab(group='org.apache.lucene', module='lucene-highlighter',  
version='3.0.3'),  
groovy\> @GrabExclude(group='xerces', module='xercesImpl')])  
groovy\> import groovyx.net.http.\*  
groovy\> import static groovyx.net.http.Method.\*  
groovy\> import static groovyx.net.http.ContentType.\*  
groovy\> import org.elasticsearch.common.xcontent.\*  
groovy\> import static org.elasticsearch.common.xcontent.XContentFactory.\*  
groovy\> import org.elasticsearch.groovy.node.GNode  
groovy\> import org.elasticsearch.groovy.client.\*  
groovy\> import org.elasticsearch.groovy.node.GNodeBuilder  
groovy\> import static org.elasticsearch.groovy.node.GNodeBuilder.\*  
groovy\> // Conectar con el servidor ES.  
groovy\> GNode node = nodeBuilder().node();  
groovy\> GClient client = node.client();  
groovy\> println client  
groovy\> node.close()

Exception thrown  
08-Feb-2011 17:17:03 org.codehaus.groovy.runtime.StackTraceUtils sanitize

WARNING: Sanitizing stacktrace:

org.elasticsearch.env.FailedToResolveConfigException: Failed to  
resolve config path [names.txt], tried file path [names.txt], path  
file [C:\develop\Groovy-1.7.6\bin\config\names.txt], and classpath

```
at org.elasticsearch.env.Environment.resolveConfig(Environment.java:163)

```

On 8 February 2011 16:50, Enrique Medina Montenegro  
[e.medina.m@gmail.com](mailto:e.medina.m@gmail.com) wrote:

> Hi David,  
> Try this out. It worked for me:  
> [Play around ES with Groovy console · GitHub](https://gist.github.com/816732)  
> Regards.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [February 8, 2011, 6:14pm UTC](https://discuss.elastic.co/t/playing-with-groovyconsole/3900/4 "2011-02-08T18:14:59Z")

</div>

There is a single groovy client, no need for the client-groovy, just the lang-groovy (it was renamed). And it should be the same version as ES repo.

That names.txt file should be in the elasticsearch jar file.

-shay.banon  
On Tuesday, February 8, 2011 at 7:19 PM, David HernÃ¡ndez wrote:

> I'm afraid it doesn't ☹
> 
> groovy\> @GrabResolver(name='Codehaus', root='[http://repository.codehaus.org](http://repository.codehaus.org)')  
> groovy\> @GrabResolver(name='Codehaus.Snapshots',  
> root='[http://snapshots.repository.codehaus.org](http://snapshots.repository.codehaus.org)')  
> groovy\> @GrabResolver(name='Codehaus.Snapshots',  
> root='[Central Repository:](http://oss.sonatype.org/content/repositories/releases/)')  
> groovy\> @GrabResolver(name='Codehaus.Snapshots',  
> root='[http://repo1.maven.org/maven2/](http://repo1.maven.org/maven2/)')  
> groovy\> @Grapes([  
> groovy\> @Grab(group='org.codehaus.groovy.modules.http-builder',  
> module='http-builder', version='0.5.1'),  
> groovy\> @Grab(group='org.elasticsearch',  
> module='elasticsearch-client-groovy', version='0.10.0'),  
> groovy\> @Grab(group='org.elasticsearch',  
> module='elasticsearch-lang-groovy', version='0.14.3'),  
> groovy\> @Grab(group='org.apache.lucene', module='lucene-highlighter',  
> version='3.0.3'),  
> groovy\> @GrabExclude(group='xerces', module='xercesImpl')])  
> groovy\> import groovyx.net.http.\*  
> groovy\> import static groovyx.net.http.Method.\*  
> groovy\> import static groovyx.net.http.ContentType.\*  
> groovy\> import org.elasticsearch.common.xcontent.\*  
> groovy\> import static org.elasticsearch.common.xcontent.XContentFactory.\*  
> groovy\> import org.elasticsearch.groovy.node.GNode  
> groovy\> import org.elasticsearch.groovy.client.\*  
> groovy\> import org.elasticsearch.groovy.node.GNodeBuilder  
> groovy\> import static org.elasticsearch.groovy.node.GNodeBuilder.\*  
> groovy\> // Conectar con el servidor ES.  
> groovy\> GNode node = nodeBuilder().node();  
> groovy\> GClient client = node.client();  
> groovy\> println client  
> groovy\> node.close()
> 
> Exception thrown  
> 08-Feb-2011 17:17:03 org.codehaus.groovy.runtime.StackTraceUtils sanitize
> 
> WARNING: Sanitizing stacktrace:
> 
> org.elasticsearch.env.FailedToResolveConfigException: Failed to  
> resolve config path [names.txt], tried file path [names.txt], path  
> file [C:\develop\Groovy-1.7.6\bin\config\names.txt], and classpath
> 
> at org.elasticsearch.env.Environment.resolveConfig(Environment.java:163)
> 
> On 8 February 2011 16:50, Enrique Medina Montenegro  
> [e.medina.m@gmail.com](mailto:e.medina.m@gmail.com) wrote:
> 
> > Hi David,  
> > Try this out. It worked for me:  
> > [Play around ES with Groovy console · GitHub](https://gist.github.com/816732)  
> > Regards.

---

<div class="post-metadata">

**Author:** ![David\_Hernandez](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/david_hernandez/32/3270_2.png) [@David\_Hernandez](https://discuss.elastic.co/u/David_Hernandez)\
**Post date:** [February 8, 2011, 6:29pm UTC](https://discuss.elastic.co/t/playing-with-groovyconsole/3900/5 "2011-02-08T18:29:39Z")

</div>

Still not working with the correct client but I put manually  
"names.txt" in C:\develop\Groovy-1.7.6\bin\config\names.txt  
and it works like a charm.

It could be a classpath issue using Groovy Console

Here the code:

@GrabResolver(name='elasticsearch',root='[http://oss.sonatype.org/content/groups/staging/](http://oss.sonatype.org/content/groups/staging/)')  
@GrabResolver(name='maven', root='[http://repo1.maven.org/maven2/](http://repo1.maven.org/maven2/)')  
@Grab('org.elasticsearch:elasticsearch-lang-groovy:0.14.4')  
import org.elasticsearch.groovy.client.GClient  
import org.elasticsearch.groovy.node.GNode  
import org.elasticsearch.groovy.node.GNodeBuilder  
import static org.elasticsearch.groovy.node.GNodeBuilder.\*

GNodeBuilder nodeBuilder = nodeBuilder();  
nodeBuilder.settings {  
node {  
client = true  
}  
cluster {  
name = "elasticsearch"  
}  
}  
GNode node = nodeBuilder.node()  
node.stop().close()

org.elasticsearch.env.FailedToResolveConfigException: Failed to  
resolve config path [names.txt], tried file path [names.txt], path  
file [C:\develop\Groovy-1.7.6\bin\config\names.txt], and classpath

```
at org.elasticsearch.env.Environment.resolveConfig(Environment.java:191)

```

On 8 February 2011 18:14, Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com) wrote:

> There is a single groovy client, no need for the client-groovy, just the  
> lang-groovy (it was renamed). And it should be the same version as ES repo.  
> That names.txt file should be in the elasticsearch jar file.  
> -shay.banon

---

<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 6, 2017, 4:12am UTC](https://discuss.elastic.co/t/playing-with-groovyconsole/3900/6 "2017-07-06T04:12:21Z")

</div>


