Getting error when try to create embedded elasticseach server. org.elasticsearch.common.settings.Settings.settingsBuilder()Lorg/elasticsearch/common/settings/Settings$Builder;


(Mansoor Ahmed) #1

Here is my pom:

org.springframework.boot
spring-boot-starter-parent
1.5.8.RELEASE

<properties>
	<!-- <org.springframework-version>4.2.5.RELEASE</org.springframework-version> 
		<org.aspectj-version>1.6.10</org.aspectj-version> -->
	<org.slf4j-version>1.7.13</org.slf4j-version>
	<jackson.databind-version>2.6.4</jackson.databind-version>
	<elasticsearch.version>1.7.4</elasticsearch.version>
	<springdata-elasticsearch>1.3.1.RELEASE</springdata-elasticsearch>
	<!-- <spring-security-version>4.0.4.RELEASE</spring-security-version> -->
	<hsqldb-version>2.3.4</hsqldb-version>
</properties>

<dependencies>

	<!-- Spring Boot Dependencies -->
	<!-- <dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-aop</artifactId>
	</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-data-jpa</artifactId>
	</dependency>
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-data-rest</artifactId>
	</dependency>
	<!-- <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jdbc</artifactId> 
		</dependency> -->
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-security</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-websocket</artifactId>
	</dependency>

	<dependency>
		<groupId>mysql</groupId>
		<artifactId>mysql-connector-java</artifactId>
		<scope>runtime</scope>
	</dependency>

	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-test</artifactId>
		<scope>test</scope>
	</dependency>
	<dependency>
		<groupId>org.springframework.security</groupId>
		<artifactId>spring-security-test</artifactId>
		<scope>test</scope>
	</dependency>
	<!-- Jackson Jar Dependency -->
	<!-- <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> 
		<version>${jackson.databind-version}</version> </dependency> -->
	<!-- Spring -->
	<dependency>
		<groupId>org.springframework</groupId>
		<artifactId>spring-context</artifactId>
		<exclusions>
			<exclusion>
				<groupId>commons-logging</groupId>
				<artifactId>commons-logging</artifactId>
			</exclusion>
		</exclusions>
	</dependency>

Following in elasticsearch config:

@Configuration

@EnableElasticsearchRepositories(basePackages = "com.tiss.tip.dal.repository")
@EnableAutoConfiguration(exclude= { ElasticsearchAutoConfiguration.class })
public class EsConfig implements DisposableBean{

@Value("${elasticsearch.host}")
private String EsHost;

@Value("${elasticsearch.port}")
private int EsPort;

@Value("${elasticsearch.clustername}")
private String EsClusterName;


private NodeClient client;

@Bean
public Client client() throws Exception {

    try {
        NodeBuilder nodeBuilder = new NodeBuilder();
        nodeBuilder
                .clusterName(EsClusterName)
                .local(false);
        nodeBuilder.settings()
                .put("http.enabled", true);
        this.client = (NodeClient)nodeBuilder.node().client();
        return this.client;
    }
    catch (Exception ex) {
        throw new IllegalStateException(ex);
    }
}

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

@Override
public void destroy() throws Exception {
    if (this.client != null) {
        try {
            if (this.client != null) {
                this.client.close();
            }
        }
        catch (final Exception ex) {
        	ex.printStackTrace();
        }
    }
}

}

Here is full stacktrace:


Kindly help me I am stuck with this issue.
Thanks.


(David Pilato) #2

I did not look at the logs but anyway embedding elasticsearch is not supported.


(Mansoor Ahmed) #3

Yeah I know but I am using elastic 1.7.4. Can you see at logs and tell me about the problem?


(David Pilato) #4

Elasticsearch 1.7 is no longer supported.

Use something like Transport Client. If you really need a Node Client, then run an elasticsearch node locally and connect the TransportClient to it. As explained in https://www.elastic.co/guide/en/elasticsearch/client/java-api/2.4/client-connected-to-client-node.html


(Mansoor Ahmed) #5

ok.
Thanks.


(system) #6

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