org.elasticsearch.join.ParentJoinPlugin giving error


(Ritwik Jain) #1

Hi,

I am creating the connection of elastic search 6.4.1 with my spring boot application with help of transportclient but there are stack of exception coming :-

Failed to instantiate [org.elasticsearch.client.Client]: Factory method 'client' threw exception; nested exception is java.lang.IllegalArgumentException: NamedWriteable [org.elasticsearch.index.query.QueryBuilder][parent_id] is already registered for [org.elasticsearch.search.SearchModule$$Lambda$756/688426301], cannot register [org.elasticsearch.join.ParentJoinPlugin$$Lambda$766/1660136848]


(Alexander Reelsen) #2

can you share some code please, how you are instantiating the transport client? That might be a bug...


(Ritwik Jain) #3

does elastic search have to do anything with springboot version?


(Ritwik Jain) #4

I am sharing my snapshot of pom file :-

I am using 2.0.0.M3 version of spring-boot-starter-parent and this is giving error but when I used 2.0.5 version of spring boot it works fine

org.springframework.boot spring-boot-starter-parent 2.0.0.M3 org.springframework.data spring-data-elasticsearch 3.0.10.RELEASE
	<dependency>
		<groupId>org.elasticsearch.client</groupId>
		<artifactId>transport</artifactId>
		<version>6.4.0</version>
	</dependency>
	
	<dependency>
		<groupId>org.apache.logging.log4j</groupId>
		<artifactId>log4j-api</artifactId>
		<version>2.11.1</version>
	</dependency>
	
	<dependency>
		<groupId>org.apache.logging.log4j</groupId>
		<artifactId>log4j-core</artifactId>
		<version>2.11.1</version>
	</dependency>
	<!-- https://mvnrepository.com/artifact/org.elasticsearch.plugin/parent-join-client -->
	
	
	
	<dependency>
		<groupId>org.apache.logging.log4j</groupId>
		<artifactId>log4j-web</artifactId>
		<version>2.11.1</version>
	</dependency>

These are the major dependecies I am using


(Ritwik Jain) #5

import java.net.InetAddress;
import java.net.UnknownHostException;

import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.transport.client.PreBuiltTransportClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;

@Configuration
@EnableElasticsearchRepositories(basePackages = "com.dao.elasticSearch")
@ComponentScan(basePackages = { "com.service.elasticSearch" })
public class ElasticSearchConfiguration {

    @Bean
    public Client client() {
        TransportClient client = null;
        try {

// final Settings elasticsearchSettings = Settings.builder()
// .put("client.transport.sniff", true)InetSocketTransportAddress
// .put("path.home", elasticsearchHome)
// .put("cluster.name", clusterName).build();
client = new PreBuiltTransportClient(Settings.EMPTY);
client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("127.0.0.1"), 9300));
} catch (UnknownHostException e) {
e.printStackTrace();
}
// client = new PreBuiltTransportClient(Settings.EMPTY);
// client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("127.0.0.1"), 9300));

        return client;
    }

    @Bean
    public ElasticsearchOperations elasticsearchTemplate() {
        return new ElasticsearchTemplate(client());
    }

}


(Ritwik Jain) #6

The issue was with the maven version. Solved by using latest one.


(system) #7

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