I'm creating an application using Spring Boot and also Elastic-Search. Spring application part is working. And also when I start Elastic server, it's also running well. No issues at all. I can test it via POSTMAN and also CURL. Adding and also searching works well.
But when I run the application, i'm getting following issues.
This is the issue i'm getting in the IDE. (which means from my java application)
org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [{#transport#-1}{127.0.0.1}{127.0.0.1:9300}]
And this is the issue i'm getting from the Elasctic server on my local system.
java.lang.IllegalStateException: Received message from unsupported version: [2.0.0] minimal compatible version is: [5.0.0]
These are the libraries I'm using.
Spring Boot 1.5.1.RELEASE
Spring Boot Starter Data Elasticsearch 1.5.1.RELEASE
Spring Data Elasticsearch 2.10.RELEASE
Elastic Search 5.0
I think this is a issue with Elastic and above library version mismatch.
I'm new to Elastic and also Spring. The version issue is here.
https://github.com/spring-projects/spring-data-elasticsearch/wiki/Spring-Data-Elasticsearch---Spring-Boot---version-matrix
And also here is my pom.xml. If I need to update any library, can anyone tell me what's that ? And also tell me how to update those libraries ? Can I update them without changing to my source code ?
<?xml version="1.0" encoding="UTF-8"?>
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
<artifactId>springboot-springdata-elasticsearch-example</artifactId>
<packaging>jar</packaging>
<url>https://www.mkyong.com</url>
<version>1.0</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.1.RELEASE</version>
</parent>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- Runtime, for Embedded Elasticsearch,
comment this if connect to external elastic search server-->
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Package as an executable jar/war -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
In this pom.xml , I can't find all the dependencies too.
According to the versions matrix that you provided, the spring boot version that you're using is not compatible with ElasticSearch 5.x instances. So, i think you have 3 options:
If you really need to work with SpringBoot 1.5.1 using ElasticSearch 5.0, you should add the maven dependencies related to ElasticSearch 5.0 and implement your own DAO service.
You can try to downgrade your ElasticSearch version to 2.4 in order to make it compatible with your current spring boot version.
Maybe you can try to use the recent spring boot version (1.5.4) because arcording to the spring-data-elasticsearch project (https://github.com/spring-projects/spring-data-elasticsearch/), the last version supports ElasticSearch 5.x, so probably it could be the easiest way.
Please let me know if any of options above was useful for you.
Related
I am trying to make SqsListener work but I can't with Spring Boot 3, it simply doesn't receive anything. When I change Spring Boot version back to 2.X everything's work perfectly.
I am using 2.4.2 version of Spring cloud:
...
<dependency>
<groupId>io.awspring.cloud</groupId>
<artifactId>spring-cloud-starter-aws-messaging</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.awspring.cloud</groupId>
<artifactId>spring-cloud-aws-dependencies</artifactId>
<version>2.4.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Can you please point me to the correct version of spring cloud?
Would I need to use milestone version for that?
It doesn't work as version 2.4.2 of spring-cloud-starter-aws-messaging relies on spring.factories for Spring Boot autoconfiguration, but the support for that has been removed in Spring Boot 3.0.0. See https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.0-Migration-Guide#auto-configuration-files.
You can enable the auto configuration by creating the following file
src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
# content
io.awspring.cloud.autoconfigure.messaging.SqsAutoConfiguration
But, it probably won't work anyway as spring-cloud-aws also relies on classes from Spring Messaging that were deprecated and removed in Spring 6 (which is used in Spring Boot 3), specifically org.springframework.messaging.handler.annotation.support.PayloadArgumentResolver.
You'll have to wait for Spring Cloud AWS to support Spring Boot 3. They are working on Spring Cloud AWS 3.0.0, but I don't think it has a release date yet. https://github.com/awspring/spring-cloud-aws
I'm not an expert about versions of spring boot starters and have faced with problem. I'm trying build my project with this spring boot starter. And I need the embedded libraries version to be 5.2.0 as it says in description of this jar file. But when I added this dependency into my project I found that embedded libraries versions are different that I expected. My maven plugins shows that versions 5.1.6 and my code doesn't compile because some classes depend on methods from 5.2.0 module.
And there is one more thing. In another project I added the same dependency. But it's ok, versions are the same with description from maven repositoty.
There is difference between these two project. One of them with spring-boot version 2.1.9 (which not compiles) and another - 2.3.4 (whihk works good). And when I checked versions of containing into starter libraries via artefactId in pom - they are ok and 5.2.0.
Here pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>adapters</artifactId>
<groupId>com.alarislabs</groupId>
<version>0.0.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>security</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
<version>2.2.0.RELEASE</version>
</dependency>
</dependencies>
I've tried to delete m2 repo with all maven dependencies and then download again but I still have problem. I've made a mistake in pom.xml? Maybe is something wrong with my IntelliJ?
Versions of dependency in pom
Wrong versions in plugin
Correct versions in plugin
Spring Boot manages several dependencies versions so that we can ensure they are compatible with each other.
Look at this pom.xml file to see which dependencies version are managed by Spring Boot 2.3.4.RELEASE. You can change the version number and see the managed dependencies in that version.
https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-dependencies/2.3.4.RELEASE/spring-boot-dependencies-2.3.4.RELEASE.pom
Benefits:
If you want to use a dependency out of the dependency list, you do not need to specify the version in in your pom.xml. Or check if an official spring-boot-starter for that dependency exists. If it exists, just use the spring-boot-starter dependency. Again no need to specify the version.
Spring will pull the dependency that works well with all other libraries so that you won't get compatibility (runtime or compile time) error
When you upgrade spring boot's version, all the managed dependencies will get updated. And also the compatibility is maintained.
How to solve your problem:
In your pom.xml, you don't need to specify the version for spring-boot-starter-oauth2-resource-server. This library is managed by spring boot. It looks you are specifying version 2.2.0 which is not compatible with your spring boot version 2.1.9.
The requirement is to use spring boot version 2.2.6.RELEASE however the tomcat version should be 9.0.37.
I tried to do it by excluding the tomcat starter from the spring-boot-starter-web depdendency like so :
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${spring-boot.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
And added the spring-boot-starter-tomcat separately which has the 9.0.37 tomcat version :
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<version>2.3.2.RELEASE</version>
</dependency>
However even after doing so the version is not override and the following gets used :
Mar 11 2020 09:31:38 UTC
Apache Tomcat/9.0.33
9.0.33.0
Do we need to do anything else to override the tomcat version?
Is it possible to override it by excluding started?
Update:
The parent pom is a corporate parent pom and not the spring-boot-starter-parent. As per one of the answers we can simply override the tomcat.version property however my effective pom doesn't show it.
If you're not inheriting from spring-boot-starter-parent I can only guess that you import spring-boot-dependencies in your dependencies management somewhere.
The documentation covers what you need to do to override the tomcat version. Each tomcat artifact should be listed with the overridden version, before you imports spring-boot-dependencies. The list of artifacts can be found in spring-boot-dependencies.
Using a different version of the starter is wrong (you can't mix two Spring Boot versions in the same app) and will have no effect since dependency management is in control anyway. In other words, you'll get spring-boot-starter-web version 2.3.2.RELEASE indeed but all the artefacts that it brings will be managed by the dependency management (the tomcat version defined by version 2.2.6.RELEASE).
In that particular case of yours, upgrading to 2.2.9.RELEASE could also be an option as it provides dependency management for the tomcat version that you need.
Well, this has been already answered.
For you, as you are using maven, you need to override the properties set in parent Spring pom.
<properties>
......
<tomcat.version>your_version</tomcat.version>
......
<properties>
For gradle, it is simple as
ext['tomcat.version'] = '8.5.34'
in your main build.gradle
Source: How to change embedded tomcat's version in existing spring boot app?
I have a Spring Boot application integrated with ElasticSearch.
When i am trying to add Apache Mahout as a maven dependency, the application is no longer running with this error:
Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/apache/lucene/util/Accountable
If i remove the mahout dependency the application is running.
pom.xml:
<dependencies>
<dependency>
<groupId>org.apache.mahout</groupId>
<artifactId>mahout-core</artifactId>
<version>0.9</version>
</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.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
The dependency is resolved by maven, the project compiles with no error but when i start it, the server stops.
Any idea?
Thank you
In order to use the latest versions of Elasticsearc v6.x and Spring-boot, you have to focus on the matrix versions. because while I was trying to integrate Elasticsearch v6.2.2 as dependencies into my spring-boot v1.5.X I faced several errors. thus spring-boot v2.x is the compatible one with ES v6.x
so the following link will help you to know the matrix between versions for your project :
https://www.elastic.co/support/matrix#matrix_compatibility
after doing that , use the last version of apache mahout .
This is my pom.xml
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
it.test
searchTest
0.0.1-SNAPSHOT
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.M5</version>
</parent>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- Runtime, for Embedded Elasticsearch,
comment this if connect to external elastic search server-->
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Package as an executable jar/war -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
When I start my project I have returned this stack trace:
[2017-12-15T13:36:15,670][WARN ][o.e.t.n.Netty4Transport ] [node1] exception caught on transport layer [org.elasticsearch.transport.netty4.NettyTcpChannel#7c08d374], closing connection
java.lang.IllegalStateException: Received message from unsupported version: [5.5.3] minimal compatible version is: [5.6.0]
at org.elasticsearch.transport.TcpTransport.ensureVersionCompatibility(TcpTransport.java:1428) ~[elasticsearch-6.1.0.jar:6.1.0]
at org.elasticsearch.transport.TcpTransport.messageReceived(TcpTransport.java:1375) ~[elasticsearch-6.1.0.jar:6.1.0]
at org.elasticsearch.transport.netty4.Netty4MessageChannelHandler.channelRead(Netty4MessageChannelHandler.java:64) ~[transport-netty4-6.1.0.jar:6.1.0]
What I have to change in my pom to solve this incompatibility?
Thanks
Change the transport version to be the same as your elasticsearch instance
What is the version of your ElasticSearch, Maybe you can try to add this property in your pom like this.
<properties>
<elasticsearch.version>6.1.0</elasticsearch.version>
</properties>
I always find the Spring data elasticsearch matrix table useful for figuring out what compatible version to use.
To change version of ES from to a compatible version use the Spring Boot dedicated module to specify dependency versions. Add elasticsearch.version into your pom properties
<properties>
...
<elasticsearch.version>1.7.2</elasticsearch.version>
...
</properties>
i too was getting similar error but got resolved, before which i like to highlight my spring boot starter parent version which is 1.5.9.RELEASE, secondly i was using spring-boot-starter-data-elasticsearch artifact alone for spring boot elastic search and other artifacts can be removed, finally the phenomenal issue which you are receiving with the elastic search application which you have installed, try to download this version https://www.elastic.co/downloads/past-releases/elasticsearch-2-4-0 and try again....