Correct the classpath of your application so that it contains a single, compatible version of org.elasticsearch.client.IndicesClient - spring-boot

Getting Error Like
An attempt was made to call the method org.elasticsearch.client.IndicesClient.create(Lorg/elasticsearch/action/admin/indices/create/CreateIndexRequest;[Lorg/apache/http/Header;)
Lorg/elasticsearch/action/admin/indices/create/CreateIndexResponse; but it does not exist. Its class, org.elasticsearch.client.IndicesClient, is available from the following locations:
jar:file:/audit.jar!/BOOT-INF/lib/elasticsearch-rest-high-level-client-6.7.0.jar!/org/elasticsearch/client/IndicesClient.class
It was loaded from the following location:
jar:file:/audit.jar!/BOOT-INF/lib/elasticsearch-rest-high-level-client-6.7.0.jar!
Please Help me out to solve this issue

Spring Boot 2.1.x uses Spring Data Elasticsearch 3.1.x which in turn is built against the libraries of Elasticsearch 6.2.2.
If you want to use Elasticsearch 6.8.5 you need to upgrade your Spring Data Elasticsearch version to 3.2.3 which is built against Elasticsearch 6.8.4.
I don't know if Spring Boot 2.1.0 can handle this in it's autoconfiguration, you might have to annotate your application with:
#SpringBootApplication(exclude = ElasticsearchDataAutoConfiguration.class)
and configure Spring Data Elasticsearch by yourself.

Related

RestHighLevelClient Bean for elasticsearch not found on classpath in spring boot 3

I am trying to upgrade my existing spring boot 2.7.x project to spring boot 3.x.x.
I have sorted out everything except this error while running the application.
APPLICATION FAILED TO START
Description:
Parameter 0 of method lockProvider in com.cox.config.ShedLockConfiguration required a bean of type 'org.elasticsearch.client.RestHighLevelClient' that could not be found.
Action:
Consider defining a bean of type 'org.elasticsearch.client.RestHighLevelClient' in your configuration.
Process finished with exit code 0
Spring Boot Version used is 3.0.0
I am aware that RestHighLevelClient is deprecated, but documentation says it's still available in spring-data-elasticsearch
Tried upgrading all dependencies to be compatible with spring boot 3
Update:
Also getting below error for another component with elastic search which I am trying to upgrade to spring boot 3
APPLICATION FAILED TO START
Description:
Parameter 2 of constructor in com.cox.service.esindex.EsIndexRefreshService required a bean of type 'org.springframework.data.elasticsearch.core.ElasticsearchOperations' that could not be found.
Action:
Consider defining a bean of type 'org.springframework.data.elasticsearch.core.ElasticsearchOperations' in your configuration.
It looks like spring boot is no longer creating beans for deprecated methods/classes. Can you please help me map each deprecated method/class with the new spring-data-elasticsearch
The documentation explicitly states:
The old deprecated RestHighLevelClient can still be used, but you will need to add the dependency explicitly to your application as Spring Data Elasticsearch does not pull it in automatically anymore:
Edit 18.02.2023:
Check the documentation it also documents how to configure the different clients. You will have to do this configuraiton by yourself, I don't think that Spring Boot will configure this automatically, they are using the current stuff from Spring Data Elasticsearch .

Can GraphQL server be built with Spring Boot version less than 2.x?

I am adding GraphQL schema wiring to my legacy microservices. I want to embed the wiring inside each of the spring boot services; The challenge I am running into is my project's Spring boot version is 1.4.5 RELEASE and moving it up to 2.x runs into others issues and would be ideal if I can get a basic graphql schema wiring done without updating version to 2.x. I see from documentation that minimal Spring boot version needed is 2.2.x in articles like this:
https://www.graphql-java.com/tutorials/getting-started-with-spring-boot/
According to the gradle build file for the graphql-java-spring library (https://github.com/graphql-java/graphql-java-spring/blob/master/build.gradle) the oldest supported Spring versions are:
springVersion = "5.1.2.RELEASE"
springBootVersion = "2.1.0.RELEASE"
You can try to compile it with an earlier spring boot version, but there is probably a lot of work to do.

Springboot - MongoDB - ValueObject unavailable in mapreduce package

Im doing the mapReduce example provided in spring mongodb documentation, however, the class ValueObject is not available in spring mongodb package:
org.springframework.data.mongodb.core.mapreduce
Eventhough, it is available in the spring github repo
I am using spring boot version 1.5.9.RELEASE
EDIT: One can easily implement it and use it. I am just wondering, did they remove it because it is easy to implement?

Get errors when using certain versions of spring boot cloud and spring boot. How can I know which versions go together?

Is there something in Maven that will tell me that if I'm using version 1.5.4 of spring-boot then I need at least version Camden.SRX for spring-cloud-starter-parent?
I was getting non-helpful errors that a class was not found as I was using Spring 1.5.4 and Brixton for cloud.
Is there a way to use Maven to find matching/compatible versions?

Spring Boot blows up when using solrj but not spring-boot-starter-data-solr

I am trying to port an existing Spring application across to Spring Boot. I am NOT using the spring-boot-starter-data-solr starter however I have apache solrj (5.0.0) on my classpath.
During startup the app blows up. It seems that spring boot sees the solr classes and assumes that I also have spring-boot-starter-data-solr on the classpath. In particular I get this error:
java.lang.IllegalArgumentException: #ConditionalOnMissingBean
annotations must specify at least one bean (type, name or annotation)
If I drop the solrj dependency and use spring-boot-starter-data-solr instead it is ok. However I don't need the spring-data-solr integration and doing so will force me to backport our app to the 4.7.x release of solr.
Is anyone aware of a workaround for this?
So it seems the problem was caused by spring boot's dependency on solrj 4.7.x whereas I am using 5.0.0
I fixed it by using
#SpringBootApplication(exclude = {SolrAutoConfiguration.class})
To tell boot to ignore the SolrAutoConfiguration completely.

Resources