0

I'm trying to set up a running service which uses Elasticsearch with Shield. However when I try to start the service I get the following error:

org.springframework.beans.factory.BeanCreationException: 
Could not autowire field: private java.util.List com.company.AppConfig.identConfigs; 
nested exception is org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'demoident' defined in URL [file:C:/path/to/config/foo.xml]: 
Cannot resolve reference to bean 'bar_client' while setting bean property 'searchClients' 
with key [TypedStringValue: value [default], target type [null]]; 
nested exception is org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'bar_client' defined in URL 
[file:C:/path/to/config/foo.xml]: Bean instantiation via constructor failed; 
nested exception is org.springframework.beans.BeanInstantiationException:
Failed to instantiate [com.company.ElasticSearchClient]: 
Constructor threw exception; nested exception is 
org.elasticsearch.common.inject.CreationException: Guice creation errors:

1) A binding to org.elasticsearch.shield.transport.filter.IPFilter was already configured 
    at _unknown_. at _unknown_

2) A binding to org.elasticsearch.shield.transport.ClientTransportFilter was already configured 
    at _unknown_. at _unknown_

3) A binding to org.elasticsearch.shield.ssl.ClientSSLService was already configured 
    at _unknown_. at _unknown_

4) A binding to org.elasticsearch.shield.ssl.ServerSSLService was already configured 
    at _unknown_. at _unknown_

4 errors
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:561)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)

(Sorry for the ugly formatting of stacktrace, feel free to edit for readability)

If I remove the Maven dependency for Elasticsearch Shield then the service starts as expected, without stacktraces, but obviously won't be able to execute any queries because of the exclusion of Shield.

Any help or input at all would be very appreciated.

Edit: I realized that the error is thrown by the Java client, not Elastic itself.

TheShahin
  • 153
  • 1
  • 12
  • 1
    Hm, can you check what jars are resolved and used in the end in your app? I suspect Shield dependency is on a version of Elasticsearch, and your `pom` retrieves a second version of Elasticsearch from somewhere else. – Andrei Stefan Oct 27 '15 at 11:42
  • You were right in that their versions differed, (I use ES-1.7.1 and Shield-1.3.2 uses ES-1.5.0). I fixed it so that they use the same version but, alas, I still get the same error message. – TheShahin Oct 27 '15 at 12:00
  • Have you, by any chance, installed Shield twice? – Andrei Stefan Oct 27 '15 at 12:05
  • I just tried starting a new, fresh instance of Elastic and added Shield to that to make sure that there are no duplicates but still I get the same stacktrace. I should add though that it is the Java client that is causing the error, not Elastic itself. – TheShahin Oct 27 '15 at 12:55
  • 1
    The same points I mentioned above applies for your client code as well: make sure one Shield version exists in the classpath, make sure one ES version exists in the classpath, the ES nodes version should be the same with the ES version your client is using. – Andrei Stefan Oct 27 '15 at 13:33
  • Sorry I forgot to reply to you, but you were indeed right. It just wasn't obvious that this was the case because a coworker, out of curiosity, tried to run the deployable and that worked fine, yet executing `mvn jetty:run` does not... So we're stuck in some kind of Maven hell that none of us can figure out. Anyways, thanks a lot for your help. – TheShahin Nov 05 '15 at 19:03

0 Answers0