Elasticsearch version for Spring Boot 2.1 - java

In my Spring Boot(2.0.5) project I was using Elasticsearch(5.6.9). However, due to some bugs in testing environment we are moving to Spring boot(2.1.0).
When I run the application the following message comes up:
***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call the method org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequestBuilder.execute()Lorg/elasticsearch/action/ActionFuture; but it does not exist. Its class, org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequestBuilder, is available from the following locations:
jar:file:/C:/Users/User/.m2/repository/org/elasticsearch/elasticsearch/5.6.9/elasticsearch-5.6.9.jar!/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequestBuilder.class
It was loaded from the following location:
file:/C:/Users/User/.m2/repository/org/elasticsearch/elasticsearch/5.6.9/elasticsearch-5.6.9.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequestBuilder
Process finished with exit code 0
Current pom.xml file
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.0.RELEASE</version>
<relativePath/>
</parent>
<properties>
<elasticsearch.version>5.6.9</elasticsearch.version>
</properties>
<dependencies>
<!--...others...-->
<!--ELASTICSEARCH-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
<version>${elasticsearch.version}</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.plugin</groupId>
<artifactId>transport-netty4-client</artifactId>
<version>${elasticsearch.version}</version>
</dependency>
</dependencies>
Previous pom.xml file which worked fine:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.5.RELEASE</version>
<relativePath/>
</parent>
<properties>
<elasticsearch.version>5.6.9</elasticsearch.version>
</properties>
<dependencies>
<!--...others...-->
<!--ELASTICSEARCH-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
<version>${elasticsearch.version}</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.plugin</groupId>
<artifactId>transport-netty4-client</artifactId>
<version>${elasticsearch.version}</version>
</dependency>
</dependencies>
Can someone tell which version of elasticsearch is compatible with Spring Boot 2.1.0?
I read through similar questions which were outdated.
Compatible versions of Spring boot,elasticsearch and spring data elasticsearch

You can go to Spring Boot project Github repository and check any dependency version:
In Spring Boot 2.0.x Elasticsearch version is defined as 5.6.16 (link)
In Spring Boot 2.1.x Elasticsearch version is defined as 6.4.3
(link)

Not sure if it's still actual, but the first thing you need to try is to add core Elasticsearch library, because REST client depends on it.
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>6.7.0</version>
</dependency>

Related

The following method did not exist: com.mongodb.connection.ClusterSettings.getDescription()Ljava/lang/String;

I use this dependency in my spring-boot 2.6.2 with spring-boot-starter-data-mongodb
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-mongodb</artifactId>
<version>5.0.0</version>
</dependency>
querydsl-mongodb uses mongo-java-driver 3.12.8 but spring-boot-starter-data-mongodb uses mongodb-driver-core
I get exception
***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
com.mongodb.connection.DefaultClusterFactory.createCluster(DefaultClusterFactory.java:182)
The following method did not exist:
com.mongodb.connection.ClusterSettings.getDescription()Ljava/lang/String;
The calling method's class, com.mongodb.connection.DefaultClusterFactory, was loaded from the following location:
jar:file:/usr/local/tomcat/webapps/app1/WEB-INF/lib/mongo-java-driver-3.12.8.jar!/com/mongodb/connection/DefaultClusterFactory.class
The called method's class, com.mongodb.connection.ClusterSettings, is available from the following locations:
jar:file:/usr/local/tomcat/webapps/app1/WEB-INF/lib/mongodb-driver-core-4.4.0.jar!/com/mongodb/connection/ClusterSettings.class
jar:file:/usr/local/tomcat/webapps/app1/WEB-INF/lib/mongo-java-driver-3.12.8.jar!/com/mongodb/connection/ClusterSettings.class
The called method's class hierarchy was loaded from the following locations:
com.mongodb.connection.ClusterSettings: file:/usr/local/tomcat/webapps/app1/WEB-INF/lib/mongodb-driver-core-4.4.0.jar
Action:
Correct the classpath of your application so that it contains compatible versions of the classes com.mongodb.connection.DefaultClusterFactory and com.mongodb.connection.ClusterSettings
The issue is due to the dependency org.mongodb mongo-java-driver
included with querydsl-mongodb.
Here https://github.com/querydsl/querydsl/issues/3134 the corresponding issue on GitHub but it does not seem to be actively
discussed.
In order to fix this issue you have to exclude the above dependency and add the org.mongodb mongo-driver-core dependency as a replacement.
Here the important parts of my pom.xml working with Spring-Boot 2.7.3
and MongoDB v5.0.8
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<java.version>18</java.version>
<querydsl.version>5.0.0</querydsl.version>
</properties>
<dependencies>
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-mongodb</artifactId>
<version>${querydsl.version}</version>
<exclusions>
<exclusion>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mongodb/mongodb-driver-core -->
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-core</artifactId>
<version>4.7.1</version>
</dependency>
</dependencies>

resilience4j + spring boot 2 + EndpointAutoConfiguration class not found exception

Resilience4j version: 1.1.0
Java version: 1.8
Spring boot : 2.2.0
I am trying to configure the Resilience4j with spring boot project but getting below class not found
org.springframework.boot.SpringApplication: Application run failed
java.lang.IllegalArgumentException: Could not find class [org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfiguration]
at org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:327)
Java Code as follows :
#RateLimiter(name ="service1",fallbackMethod = "rateLimiterfallback")
#PostMapping(value = "${URL_AUTH}")
public ResponseEntity<AuthRespDTO> fetchToken(#RequestParam("userId") String Id, #RequestParam("password") String pwd, HttpServletRequest httpRequest) {
}
application.yml as below
resilience4j.ratelimiter:
instances:
service1:
limitForPeriod: 1
limitRefreshPeriod: 100000
timeoutDuration: 1000ms
I have below dependencies mentioned in POM.xml .
<dependency>
<groupId>io.github.resilience4j</groupId>
<artifactId>resilience4j-spring-boot2</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>io.github.resilience4j</groupId>
<artifactId>resilience4j-ratelimiter</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator</artifactId>
<version>2.2.0.RELEASE</version>
</dependency>
Please help me in resolving the issue .
For fixing this issue you have to update the POM with the spring-boot-starter-actuator and spring-boot-starter-aop dependencies.
At present you have a dependency of spring-boot-actuator which should be updated to spring-boot-starter-actuator.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
<version>2.3.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<version>2.3.2.RELEASE</version>
</dependency>
Note : Release version of spring boot depends on your project.
Similar issue reference

Spring Boot & Elastic client - NoSuchMethodError: org.elasticsearch.action.support.IndicesOptions.ignoreThrottled()Z

We created a Spring Boot 2.1.7.RELEASE app with an ElasticSearch 7.3.0 client.
When trying to run the Elastic client we get the following error for this line:
SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);
Handler dispatch failed; nested exception is java.lang.NoSuchMethodError: org.elasticsearch.action.support.IndicesOptions.ignoreThrottled()Z] with root cause
java.lang.NoSuchMethodError: org.elasticsearch.action.support.IndicesOptions.ignoreThrottled()Z
at org.elasticsearch.client.RequestConverters$Params.withIndicesOptions(RequestConverters.java:966)
at org.elasticsearch.client.RequestConverters.addSearchRequestParams(RequestConverters.java:417)
at org.elasticsearch.client.RequestConverters.search(RequestConverters.java:404)
at org.elasticsearch.client.RestHighLevelClient.lambda$search$2(RestHighLevelClient.java:932)
at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1450)
at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:1424)
at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:1394)
at org.elasticsearch.client.RestHighLevelClient.search(RestHighLevelClient.java:930)
We are using these dependencies:
<properties>
<spring-boot-version>2.1.7.RELEASE</spring-boot-version>
<elasticsearch.version>7.0.0</elasticsearch.version>
</properties>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${spring-boot-version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<version>${spring-boot-version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<version>${spring-boot-version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>${spring-boot-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>7.3.0</version>
</dependency>
We found this post that caused us to add the elasticsearch.version property, but it didn't help.
We also run mvn dependency:tree -Dverbose to see if there is a conjunction of Elastic dependencies, but it seems that only the Elastic Client has Elastic related jar.
UPDATE
Following this post we tried to downgrade the Elastic client version to 7.1.1 but it didn't help
Following this answer here, we discovered that the Elastic server has a 6.5.4 version.
Changing the dependency to
<elasticsearch.version>6.5.4</elasticsearch.version>
Or
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>${elasticsearch.version}</version>
</dependency>
Solved the issue.

NIFI: No controller service types found that are applicable for this property

I am developing a Milo OPCUA Processor and Service for Apache NiFi.
The Processor and Service compile fine, and I am able to start NiFi with them. However, when trying to configure the service for the processor that I just added, it just says "No controller service types found that are applicable for this property.".
Here are my POMs:
Processor JAR
<parent>
<groupId>com.tcon</groupId>
<artifactId>pubsub</artifactId>
<version>0.1</version>
</parent>
<artifactId>nifi-pubsub-processors</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-utils</artifactId>
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-mock</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>tcon</groupId>
<artifactId>nifi-miloservice-api</artifactId>
<version>0.1</version>
</dependency>
</dependencies>
Processor NAR
<parent>
<groupId>com.tcon</groupId>
<artifactId>pubsub</artifactId>
<version>0.1</version>
</parent>
<artifactId>nifi-pubsub-nar</artifactId>
<version>0.1</version>
<packaging>nar</packaging>
<properties>
<maven.javadoc.skip>true</maven.javadoc.skip>
<source.skip>true</source.skip>
</properties>
<dependencies>
<dependency>
<groupId>com.tcon</groupId>
<artifactId>nifi-pubsub-processors</artifactId>
<version>0.1</version>
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-standard-services-api-nar</artifactId>
<version>1.2.0</version>
<type>nar</type>
</dependency>
</dependencies>
The service POMs shouldn't matter, afaik. They haven't been modified, save for a few Milo dependencies.
As you can see, the processor JAR POM has the custom service API dependency from my custom service and the processor NAR POM has the standard API dependency from nifi.
The docs say that that is all I need to do to "link" my processor to my service.
What am I missing?
You also need to register your controller service with the ServiceLoader by including a file in the src/main/resources folder of your processor JAR project. You'll need a META-INF/services folder under your resources folder, with a file called org.apache.nifi.controller.ControllerService with a line containing the fully qualified name of the class implementing the ControllerService interface.

Spring Boot REST on Google App Engine throws 502

I have been struggling with this for about a week and nothing I have seen on SO has worked for me. I have a REST API built on Spring Boot that I am trying to deploy to the Google App Engine. Running locally is fine and when I run it on the GAE emulator it works fine as well; however, once I deploy using mvn appengine:deploy I get a successful build but when trying the endpoints I only get a 502. I'm not sure where the logs are so this is really kicking my butt.
My 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">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.admin</groupId>
<artifactId>admin-api</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<!-- Exclude this for deployment only -->
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- other project dependencies -->
<dependency>
<groupId>com.google.firebase</groupId>
<artifactId>firebase-admin</artifactId>
<version>5.3.0</version>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.10.2</version>
</dependency>
<!-- end other project specific dependencies -->
<!-- Dependencies provided during deployment -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<!-- End dependencies for deployment -->
<!-- Dependencies for local -->
<!-- <dependency> -->
<!-- <groupId>org.springframework.boot</groupId> -->
<!-- <artifactId>spring-boot-starter-tomcat</artifactId> -->
<!-- <scope>provided</scope> -->
<!-- </dependency> -->
<!-- End dependencies for local -->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>1.3.1</version>
<configuration>
<project>project-id-from-GAE-here</project
</configuration>
</plugin>
</plugins>
</build>
</project>
My application class is a simple annotated #SpringBootApplication class. I have 2 controllers with annotation of #RestController and simple #RequestMapping methods. One of the REST controllers is for the /_ah/health endpoint that returns 200 since one post mentioned constant restarts being triggered by the lack of a healthcheck endpoint.
I have a simple application.yml for my value injections and created an app.yaml file placed in src/main/appengine
runtime: java
env: flexible
threadsafe: true
manual_scaling:
instances: 1
handlers:
- url: /.*
script: this field is required, but ignored
runtime_config:
jdk: openjdk8
I am at a complete loss on this. It is my first GAE deployment with hopefully more to go. (I also am not using Docker yet since I am on a Windows 10 machine that breaks when I load Docker on it.)
UPDATE
I did notice that I had forgotten to put my project id under the maven plugin. Once I did that I got errors about not finding the app.yaml. I realized that since I am using a flexible environment, I did not need the appengine-web.xml and I had my file misnamed as app.yml rather than app.yaml. I updated my question with this and I am still getting a 502 after a successful deployment.
I realized my trial period with GAE included tech support so I contacted them. The asked for my pom and app.yaml. Their response was to add the following to my app.yaml "Since Java is known for consuming high memory usage, there is an overhead process consumed more than the approximate 0.4GB value"
resources:
cpu: 2
memory_gb: 2.3
disk_size_gb: 10
volumes:
- name: ramdisk1
volume_type: tmpfs
size_gb: 0.5
They also provided this link for reference: https://cloud.google.com/appengine/docs/flexible/java/configuring-your-app-with-app-yaml#resource-settings
Once I did this, my application started working just fine.
EDIT
If you have a simple application, set cpu:1 since you get billed on CPU hours and your daily quota is 28 and with 2 CPUs you end up with 48 CPU hours. I burned through the free $300 credit in 1 month because their tutorials setup a RDB ($80) that doesn't get used and doesn't show to kill the project. Also make sure when deploying something new you delete the old versions or you will be charged for every version that is up.

Categories

Resources