What are springboot dependencies needed for ElasticSearch 5.6.7? - spring-boot

Please share me the dependencies information about using ES 5.6.7 with springboot ?
As i have ES 2.4 and it is working now, but after upgrade failing to work.

You can use :
<!-- https://mvnrepository.com/artifact/org.elasticsearch/elasticsearch -->
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>5.6.6</version>
</dependency>
You can check here for further more dependency

Related

java.lang.NoSuchMethodError: org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequestBuilder.setSource

I am trying to run the spring boot parent project which uses child project, which in turn uses project(ES project) which has elasticsearch dependencies and elasticsearch config bean for transport client.
The child project uses Spring Data ES repositories, which are enabled by a respective annotation in a project.
These are config annotations used in the child:
#Configuration
#ComponentScan("package")
#EntityScan("package3")
#EnableJpaRepositories("package2")
// enables only es repos for current project, ESProject has this annotation for its packages respectively
#EnableElasticsearchRepositories("package1")
The parent project has the only #SPringBootApplication on all packages of ES project and child one.
Parent pom:
<dependencies>
<dependency>
<groupId>org.groupid</groupId>
<artifactId>ChildProject</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
</dependency>
<!-- ... -->
</dependencies>
Child pom:
<dependencies>
<dependency>
<groupId>org.groupid</groupId>
<artifactId>ESProject </artifactId>
<version>1.1-SNAPSHOT</version>
<exclusions>
<exclusion>
<!-- exclusions -->
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
</dependency>
</dependencies>
ESProject Pom:
<dependencies>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>6.4.1</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
<version>6.4.1</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-elasticsearch</artifactId>
<version>3.1.1.RELEASE</version>
</dependency>
</dependencies>
The parent project is a module of pom, which uses Spring Boot 2.0.5.RELEASE.
When I run a parent project I am getting this. Clearly there are some dependencies conflicts but I can't quite figure out them.
nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.elasticsearch.repository.support.NumberKeyedRepository]: Constructor threw exception;
nested exception is java.lang.NoSuchMethodError: org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequestBuilder.setSource(Ljava/lang/String;)Lorg/elasticsearch/action/admin/indices/mapping/put/PutMappingRequestBuilder;
Also, it's worth noting if I use ESProject in other projects I don't get this exception but I don't have Spring Data ES Repos in those projects.
You have a pretty mix-up of Spring Data Elasticsearch and Elasticsearch library versions in your setup. Let me try to visualize what we got:
Spring Boot 2.0.5
+- Elasticsearch 5.6.11
+- Data Kay.SR10
+- Spring Data Elasticsearch 3.0.10
+- Elasticsearch 5.5.0
Boot 2.0.5 pulls in ES 5.6.11 but at the same time via the Spring Data Kay releasetrain version 5.5.0 of ES and 3.0.10 of SDES (which is not nice but should work).
Spring Data Elasticsearch 3.1.1
+- Elasticsearch 6.2.2
you define SDES 3.1.1 which relies on ES 6.2.2
Elasticsearch 6.4.1
finally you define the ES version to be 6.4.1
As for the error you see: The code that your application uses expects the following function to be available in the ES client libraries (using fully qualified names for the types):
org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequestBuilder org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequestBuilder.setSource(java.lang.String)
This method existed in ES 5.5, but was already deprecated there (excerpt from the code):
/**
* The mapping source definition.
* #deprecated use {#link #setSource(String, XContentType)}
*/
#Deprecated
public PutMappingRequestBuilder setSource(String mappingSource) {
request.source(mappingSource);
return this;
}
in ES6 this method was removed and only the one with the additional XContentType parameter exists - which is used by SDES for this version.
So your application loads SDES 3.0 in combination with ES 6 libraries which cannot work.
So you should update your dependencies to a consistent version either using Boot 2.1 or 2.2 check the version matrix here

Elasticsearch 5 connector in Apache Flink 1.3

By reading the documentation I understood that with Apache Flink 1.3 I should be able to use Elasticsearch 5.x.
However, in my pom.xml :
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-connector-elasticsearch5_2.10</artifactId>
<version>1.3.0</version>
</dependency>
I got this :
Dependency
"org.apache.flink:flink-connector-elasticsearch5_2.10:1.3.0" not found
Any idea why this dependency is unfound ?
This was a bug in the 1.3.0 release and is being fixed for 1.3.1 (which is due very soon). See the mailing list for more details.
Use the following in the pom.xml
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-connector-elasticsearch5_2.10</artifactId>
<version>1.3.1</version>
</dependency>

Apache Camel Integration with Elasticsearch

I'm working on a project using Apache Camel and Elasticsearch and I was wondering which version of Elasticsearch does Camel support?
My pom.xml looks like this:
<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>2.18.2</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-elasticsearch</artifactId>
<version>2.18.2</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-xmljson</artifactId>
<version>2.18.2</version>
</dependency>
<dependency>
<groupId>xom</groupId>
<artifactId>xom</artifactId>
<version>1.2.5</version>
</dependency>
But when I want to route a file to elasticsearch, I've got the following error:
java.lang.IllegalStateException: Received message from unsupported version: [2.0.0] minimal compatible version is: [5.0.0]
I found that this exception is due to a node or a TransportClient using an old version. So I try to add the elasticsearch dependency :
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>5.1.2</version>
</dependency>
But it gives me a new error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/elasticsearch/action/WriteConsistencyLevel
So I'm wondering.. Which version of ES can I use with Apache Camel?
The code for trying to send data to elasticsearch:
XmlJsonDataFormat xmlJsonFormat = new XmlJsonDataFormat();
from("file://C:/Projects/?fileName=data.xml&charset=utf-8")
.marshal(xmlJsonFormat)
.to("elasticsearch://clusterES?transportAddresses=127.0.0.1:9300&operation=BULK_INDEX&indexName=xml&indexType=account");
I don't think you need to add any other pom except the camel-elasticsearch. It seems more likely that you have a TransportClient running on an older version. You need to find it and upgrade the TransportClient.
https://www.elastic.co/guide/en/elasticsearch/guide/current/_transport_client_versus_node_client.html
https://discuss.elastic.co/t/received-message-from-unsupported-version-2-0-0-minimal-compatible-version-is-5-0-0/64708

What version of "mysql-connector-java" be use for Spring sts release 3.2.3?

Am using sts release version 3.2.3.for jdbc connection, i have given the dependency
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>3.2.3.RELEASE</version>
</dependency>
Its throwing error:
java.lang.NoSuchMethodError: org.springframework.beans.factory.annotation.InjectionMetadata.needsRefresh(Lorg/springframework/beans/factory/annotation/InjectionMetadata;Ljava/lang/Class;)Z
Some jar files i have used seems to be mismatch .
Can somebody please guide me which version of "mysql-connector-java" be used for spring 3.2.3 release ?? And how to know which version of jars i should used??
Thanks
The needsRefresh method was added in spring 4.0.x and it can't be found in the 3.0.x version.

Standard way of adding JSLT 1.2.1 in a Maven Project?

What is the standard pom for adding the 1.2.1 JSTL taglib in a maven project. Any recommendations as to when/if can this be scoped as provided ? Any server peculiarities (interested in Jboss 7, Glassfish 4 and/or Tomcat 7)
EDIT: Added:
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>javax.servlet.jsp.jstl</artifactId>
<version>1.2.1</version>
<scope>provided</scope>
</dependency>
This adds:
Notice it transitively adds the 1.2 api.
I am using provided as I am using Jboss which should provide it: Basic question complicated solution - Tomcat to JBoss. Still this is the 1.2 api apparently
$ find . -name *jstl*.jar
./modules/javax/servlet/jstl/api/main/jboss-jstl-api_1.2_spec-1.0.2.Final.jar
(contains implementation also). So would the correct way be to add the jstl jars to the pom (not in provided scope) and mark the servlet-api (I'm on 3 anyway) as provided somehow ?
Ended up using :
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<!-- Add the jstl-api dependency explicitly - otherwise jstl-api 1.2 is added -->
<dependency>
<groupId>javax.servlet.jsp.jstl</groupId>
<artifactId>javax.servlet.jsp.jstl-api</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>javax.servlet.jsp.jstl</artifactId>
<version>1.2.1</version>
<exclusions>
<!-- jstl-api was adding selvlet-api 2.5 and jsp-api-->
<exclusion>
<artifactId>jstl-api</artifactId>
<groupId>javax.servlet.jsp.jstl</groupId>
</exclusion>
</exclusions>
</dependency>
Not sure if I should add the jstl-api dependency - please comment (I would accept a more authoritative answer actually). Result:
See:
Autocomplete with JSP, JSTL 1.2.1 and Servlet 3.0 in Tomcat 7 with Eclipse Kepler
Fix maven JSTL 1.2.1 dependency so maven-war-plugin doesn't package JARs that offend Tomcat 7
JBoss 7.1 - Migration to JSF 2.2 - includes how to upgrate your jstl to 1.2.1
For 1.2:
Running JSTL 1.2 on Tomcat 7 using Maven

Resources