Getting An issue by Saying Cluster nodes source must not be null or empty after upgrading Spring Boot 2.1.7

HI
I am trying to upgrade my Spring boot application 2.1.7, we have used elastic search over there , while upgrading I am getting below issue
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'elasticsearchClient' defined in class path resource [org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.elasticsearch.client.transport.TransportClient]: Factory method 'elasticsearchClient' threw exception; nested exception is java.lang.IllegalArgumentException: Cluster nodes source must not be null or empty!
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.elasticsearch.client.transport.TransportClient]: Factory method 'elasticsearchClient' threw exception; nested exception is java.lang.IllegalArgumentException: Cluster nodes source must not be null or empty!
Caused by: java.lang.IllegalArgumentException: Cluster nodes source must not be null or empty!

my pom file is

org.springframework.boot
spring-boot-starter-parent
2.1.7.RELEASE


	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter</artifactId>
	</dependency>
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
	</dependency>
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-web</artifactId>
	</dependency>
		
	<dependency>
		<groupId>org.springframework.cloud</groupId>
		<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
	</dependency>
	<dependency>
		<groupId>org.springframework.cloud</groupId>
		<artifactId>spring-cloud-starter-config</artifactId>
	</dependency>

</dependencies>

<dependencyManagement>
	<dependencies>
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-dependencies</artifactId>
			<version>${spring-cloud.version}</version>
			<type>pom</type>
			<scope>import</scope>
		</dependency>
	</dependencies>
</dependencyManagement>

Welcome!

May be not your issue but when using springboot with
elasticsearch, you need to be explicit with some transitive dependencies as SpringBoot declares a version 6.4...

Basically you can put this in your pom.xml:

<properties>
  <elasticsearch.version>7.3.0<elasticsearch.version>
</properties>

See documentation here: https://docs.spring.io/spring-boot/docs/current/reference/html/howto-build.html#howto-customize-dependency-versions

HI
Thanks for your quick response ,but I added elasticSearch version as well ,
I included 6.2.2 as Spring boot 2.1.7 support elastic Search 6.2.2

<elasticsearch.version>6.2.2</elasticsearch.version>

,but after That I am getting noClassDefFound Error
see the below error
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'elasticsearchClient' defined in class path resource [org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.elasticsearch.client.transport.TransportClient]: Factory method 'elasticsearchClient' threw exception; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.springframework.data.elasticsearch.client.ClusterNodes
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.elasticsearch.client.transport.TransportClient]: Factory method 'elasticsearchClient' threw exception; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.springframework.data.elasticsearch.client.ClusterNodes
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.springframework.data.elasticsearch.client.ClusterNodes

This class org.springframework.data.elasticsearch.client.ClusterNodes does not come from elasticsearch. May be you're missing spring data elasticsearch?

spring-boot-starter-data-elasticsearch internally uses spring data elasticSearch
see the compile dependencies
https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-elasticsearch/2.1.7.RELEASE

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.