# Ec2 discovery Guice creation errors:

**URL:** <https://discuss.elastic.co/t/ec2-discovery-guice-creation-errors/11274>\
**Category:** Elasticsearch\
**Created:** [March 23, 2013, 7:38am UTC](https://discuss.elastic.co/t/ec2-discovery-guice-creation-errors/11274 "2013-03-23T07:38:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chris\_Greening](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chris_greening/32/2285_2.png) [@Chris\_Greening](https://discuss.elastic.co/u/Chris_Greening)\
**Post date:** [March 23, 2013, 7:38am UTC](https://discuss.elastic.co/t/ec2-discovery-guice-creation-errors/11274/1 "2013-03-23T07:38:46Z")

</div>

We are trying to embed elasticsearch in our spring application, but  
whenever I try to enable ec2 discovery we get the following error repeated  
many times in our log.

We are creating the node using the following code:

Settings settings = ImmutableSettings.settingsBuilder().put(settingsLoader  
.load(  
"cluster.name: es-demo\n"+  
"cloud:\n"+  
" aws:\n"+  
" access\_key: \<access\_key\>\n"+  
" secret\_key: \<secret\_key\>\n"+  
"discovery:\n"+  
" type: ec2\n"+  
"gateway:\n"+  
" type: s3\n"+  
" s3:\n"+  
" bucket: \n")).build();  
Node node = nodeBuilder().settings(settings).node();  
return node.client();

These settings worked with the standalone version of elastic fox, but in  
our spring web app. If I don't try and use ec2 discovery then I do not get  
any errors.  
This is the error - it gets repeated constantly - I think something is  
stuck in some kind of inifinite loop.

org.springframework.beans.factory.BeanCreationException: Error creating  
bean with name 'homeController': Injection of autowired dependencies  
failed; nested exception is  
org.springframework.beans.factory.BeanCreationException: Could not autowire  
field: private me.vollow.core.item.service.ItemService  
me.vollow.web.home.controller.HomeController.itemService; nested exception  
is org.springframework.beans.factory.BeanCreationException: Error creating  
bean with name 'itemService': Injection of autowired dependencies failed;  
nested exception is  
org.springframework.beans.factory.BeanCreationException: Could not autowire  
field: private me.vollow.core.fulltextsearch.IFullTextSearchService  
me.vollow.core.item.service.ItemService.fullTextSearchService; nested  
exception is org.springframework.beans.factory.BeanCreationException: Error  
creating bean with name 'fullTextSearchService': Injection of autowired  
dependencies failed; nested exception is  
org.springframework.beans.factory.BeanCreationException: Could not autowire  
field: org.elasticsearch.client.Client  
me.vollow.core.fulltextsearch.ElasticSearchService.client; nested exception  
is org.springframework.beans.factory.BeanCreationException: Error creating  
bean with name 'client' defined in class path resource  
[me/vollow/core/config/ServiceConfig.class]: Instantiation of bean failed;  
nested exception is  
org.springframework.beans.factory.BeanDefinitionStoreException: Factory  
method [public org.elasticsearch.client.Client  
me.vollow.core.config.ServiceConfig.client()] threw exception; nested  
exception is org.elasticsearch.common.inject.CreationException: Guice  
creation errors:

1. Error injecting constructor, java.lang.IllegalStateException: This is a  
proxy used to support circular references involving constructors. The  
object we're proxying is not constructed yet. Please wait until after  
injection has completed to use this object.  
at org.elasticsearch.cache.NodeCache.(Unknown Source)  
while locating org.elasticsearch.cache.NodeCache  
Caused by: java.lang.IllegalStateException: This is a proxy used to support  
circular references involving constructors. The object we're proxying is  
not constructed yet. Please wait until after injection has completed to use  
this object.  
at  
org.elasticsearch.common.inject.internal.ConstructionContext$DelegatingInvocationHandler.invoke(ConstructionContext.java:102)  
at $Proxy63.add(Unknown Source)  
at org.elasticsearch.cache.NodeCache.(NodeCache.java:44)  
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)  
.....

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [March 23, 2013, 9:43am UTC](https://discuss.elastic.co/t/ec2-discovery-guice-creation-errors/11274/2 "2013-03-23T09:43:40Z")

</div>

I assume you have different versions of Guice running. ES comes with an  
own Guice-based injector implementation, and server/client code is mixed  
in the ES jar. So you may run into all kind of dependency cycles and  
Guice conflicts. You can try to clean this up by sorting the Guice  
injections out and invoke ES with its own injector version.

Another method I can think of to embed elasticsearch in an external  
application would be to embed a transport client, not a client, because  
an org.elasticsearch.client.transport.TransportClient does not  
instantiate the whole set of service/modules an ES node contains. For  
instance there is no NodeCache in a transport client.

But I do not use Spring so I may be wrong. David is the expert 🙂

Jörg

Am 23.03.13 08:38, schrieb Chris Greening:

> We are trying to embed elasticsearch in our spring application, but  
> whenever I try to enable ec2 discovery we get the following error  
> repeated many times in our log.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 23, 2013, 10:13am UTC](https://discuss.elastic.co/t/ec2-discovery-guice-creation-errors/11274/3 "2013-03-23T10:13:21Z")

</div>

Hehe. Thanks Jörg.

Chris? Did you look at [GitHub - dadoonet/spring-elasticsearch: Spring factories for elasticsearch](https://github.com/dadoonet/spring-elasticsearch)? Looking at your stack trace you don't seem to use it, do you?

About Guice, I'm not an expert at all. I think that Elasticsearch shades Guice lib in another package so I assume that it should not conflict. That said, follow Jörg's advice and look if you have in your class path another version of guice.

If you are using Maven, a `mvn dependency:list` should help.

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 23 mars 2013 à 10:43, Jörg Prante [joergprante@gmail.com](mailto:joergprante@gmail.com) a écrit :

> I assume you have different versions of Guice running. ES comes with an own Guice-based injector implementation, and server/client code is mixed in the ES jar. So you may run into all kind of dependency cycles and Guice conflicts. You can try to clean this up by sorting the Guice injections out and invoke ES with its own injector version.
> 
> Another method I can think of to embed elasticsearch in an external application would be to embed a transport client, not a client, because an org.elasticsearch.client.transport.TransportClient does not instantiate the whole set of service/modules an ES node contains. For instance there is no NodeCache in a transport client.
> 
> But I do not use Spring so I may be wrong. David is the expert 🙂
> 
> Jörg
> 
> Am 23.03.13 08:38, schrieb Chris Greening:
> 
> > We are trying to embed elasticsearch in our spring application, but whenever I try to enable ec2 discovery we get the following error repeated many times in our log.
> 
> --  
> You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Chris\_Greening](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chris_greening/32/2285_2.png) [@Chris\_Greening](https://discuss.elastic.co/u/Chris_Greening)\
**Post date:** [March 23, 2013, 4:00pm UTC](https://discuss.elastic.co/t/ec2-discovery-guice-creation-errors/11274/4 "2013-03-23T16:00:22Z")

</div>

I found the problem straight after I posted so I tried to delete the post,  
but I guess it got through. The errors I was seeing were a bit of a red  
herring. It turns out the problem was a minor error in configuration string.

I had:

"cluster.name: es-demo\n"+  
"cloud:\n"+  
" aws:\n"+  
" access\_key: \<access\_key\>\n"+  
" secret\_key: \n"+  
"discovery:\n"+  
" type: ec2\n"+  
"gateway:\n"+  
" type: s3\n"+  
" s3:\n"+  
" bucket: \n"

It should have been this: (note the indentation of the access and secret  
key fields)

"cluster.name: es-demo\n"+  
"cloud:\n"+  
" aws:\n"+  
" access\_key: \<access\_key\>\n"+  
" secret\_key: \n"+  
"discovery:\n"+

" type: ec2\n"+  
"gateway:\n"+  
" type: s3\n"+  
" s3:\n"+  
" bucket: \n"

I'm guessing that what something was silently failing to setup properly and  
that was causing some knock on effect somewhere else.

I didn't know about [GitHub - dadoonet/spring-elasticsearch: Spring factories for elasticsearch](https://github.com/dadoonet/spring-elasticsearch) I'll  
take a look.

Thanks  
Chris.

On Saturday, March 23, 2013 10:13:21 AM UTC, David Pilato wrote:

> Hehe. Thanks Jörg.
> 
> Chris? Did you look at [GitHub - dadoonet/spring-elasticsearch: Spring factories for elasticsearch](https://github.com/dadoonet/spring-elasticsearch)?  
> Looking at your stack trace you don't seem to use it, do you?
> 
> About Guice, I'm not an expert at all. I think that Elasticsearch shades  
> Guice lib in another package so I assume that it should not conflict. That  
> said, follow Jörg's advice and look if you have in your class path another  
> version of guice.
> 
> If you are using Maven, a `mvn dependency:list` should help.
> 
> --  
> _David Pilato_ | _Technical Advocate_ | _[Elasticsearch.com](http://Elasticsearch.com)_  
> @dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr[https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr)  
> | @scrutmydocs [https://twitter.com/scrutmydocs](https://twitter.com/scrutmydocs)
> 
> Le 23 mars 2013 à 10:43, Jörg Prante \<[joerg...@gmail.com](mailto:joerg...@gmail.com) \<javascript:\>\> a  
> écrit :
> 
> I assume you have different versions of Guice running. ES comes with an  
> own Guice-based injector implementation, and server/client code is mixed in  
> the ES jar. So you may run into all kind of dependency cycles and Guice  
> conflicts. You can try to clean this up by sorting the Guice injections out  
> and invoke ES with its own injector version.
> 
> Another method I can think of to embed elasticsearch in an external  
> application would be to embed a transport client, not a client, because an  
> org.elasticsearch.client.transport.TransportClient does not instantiate the  
> whole set of service/modules an ES node contains. For instance there is no  
> NodeCache in a transport client.
> 
> But I do not use Spring so I may be wrong. David is the expert 🙂
> 
> Jörg
> 
> Am 23.03.13 08:38, schrieb Chris Greening:
> 
> We are trying to embed elasticsearch in our spring application, but  
> whenever I try to enable ec2 discovery we get the following error repeated  
> many times in our log.
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:44am UTC](https://discuss.elastic.co/t/ec2-discovery-guice-creation-errors/11274/5 "2017-07-06T02:44:59Z")

</div>


