Ec2 discovery Guice creation errors:

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.
For more options, visit https://groups.google.com/groups/opt_out.

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 :slight_smile:

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.
For more options, visit https://groups.google.com/groups/opt_out.

Hehe. Thanks Jörg.

Chris? Did you look at 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
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 23 mars 2013 à 10:43, Jörg Prante 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 :slight_smile:

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.
For more options, visit 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.
For more options, visit https://groups.google.com/groups/opt_out.

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 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 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
@dadoonet https://twitter.com/dadoonet | @elasticsearchfrhttps://twitter.com/elasticsearchfr
| @scrutmydocs https://twitter.com/scrutmydocs

Le 23 mars 2013 à 10:43, Jörg Prante <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 :slight_smile:

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 <javascript:>.
For more options, visit 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.
For more options, visit https://groups.google.com/groups/opt_out.