1

I am trying to use Jest 0.0.6 ElasticSearch client with SpringBoot 1.4 and have the following error. I think it's due to the fact that SpringBoot tries to create a Jest Client automatically along with a health check for it, but the old Jest client does not have some of the required classes.

Any ideas how to get round this?

I need to connect to an old ElasticSearch v0.90.5 server which I have no option to upgrade at this moment. If you have any ideas on how best to connect to such an old version from SpringBoot that would also be very helpful.

Caused by:org.springframework.beans.factory.UnsatisfiedDependencyException:

Error creating bean with name 'metricsEndpointMetricReader' defined in class path resource 

...

[org/springframework/boot/actuate/autoconfigure/ElasticsearchHealthIndicatorConfiguration$ElasticsearchJestHealthIndicatorConfiguration.class]: 
Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.health.HealthIndicator]: 
Factory method 'elasticsearchHealthIndicator' threw exception; nested exception is java.lang.NoClassDefFoundError: io/searchbox/action/Action; nested exception is 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration ': Bean instantiation via constructor failed; nested exception is    
org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration$$EnhancerBySpringCGLIB$$909d8b5d]: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'elasticsearchHealthIndicator' defined in class path resource [org/springframework/boot/actuate/autoconfigure/ElasticsearchHealthIndicatorConfiguration$ElasticsearchJestHealthIndicatorConfiguration.class]: Bean instantiation via factory method failed; nested exception is 
org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.health.HealthIndicator]: Factory method 'elasticsearchHealthIndicator' threw exception; nested exception is java.lang.NoClassDefFoundError: io/searchbox/action/Action

From the Spring Boot 1.4 release notes:

"Jest support

Spring Boot auto-configures a JestClient and a dedicated HealthIndicator if Jest is on the classpath. This allows you to use Elasticsearch even when spring-data-elasticsearch isn’t on the classpath."

chrismacp
  • 3,834
  • 1
  • 30
  • 37
  • please include actuator dependency in pom or gradle build file. I would recommend to go with this link http://start.spring.io to bootstrap your application. – Praveen Kumar K S Sep 09 '16 at 11:28
  • The actuators are were all working normally before this change, the missing class is from the Jest library so not sure how that would solve it? – chrismacp Sep 09 '16 at 11:42

1 Answers1

1

I found in this jest github page. If you use es 0.90.5, then you must use jest 0.0.6. And, there is a spring boot dependency parent, specify the version of jest is 2.0.3:

<jest.version>2.0.3</jest.version>

And the auto config code at : org.springframework.boot.autoconfigure.elasticsearch.jest.JestAutoConfiguration

This auto config class will load when io.searchbox.client.JestClient is added to your classpath.

This is impl by Condition frame : @ConditionalOnClass(JestClient.class).

You can find more about Condition framework here

Exclude this auto config by add exclude to start up class:

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.elasticsearch.jest.JestAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;

@SpringBootApplication
@EnableAutoConfiguration(exclude = { JestAutoConfiguration.class})
public class App {

    public static void main(String[] args) {
        SpringApplication.run(App.class, args);
    }
}

After add this exclude to you start up class. you can config jest client you own.

BeeNoisy
  • 1,254
  • 1
  • 14
  • 23
  • Thanks for the info, I managed to get approval for upgrading ES after it started breaking so now I no longer have this issue. Maybe someone else will see this and test it out though. – chrismacp Feb 15 '17 at 16:24
  • The exclude in the @EnableAutoConfiguration annotation worked for me. – Kirk B May 08 '17 at 17:46