# Errors when using spring-data-elasticsearch version 3.0.0.BUILD-SNAPSHOT and Elasticsearch 5.4.0

**URL:** <https://discuss.elastic.co/t/errors-when-using-spring-data-elasticsearch-version-3-0-0-build-snapshot-and-elasticsearch-5-4-0/90525>\
**Category:** Elasticsearch\
**Created:** [June 22, 2017, 7:52pm UTC](https://discuss.elastic.co/t/errors-when-using-spring-data-elasticsearch-version-3-0-0-build-snapshot-and-elasticsearch-5-4-0/90525 "2017-06-22T19:52:22Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![CGavrila](https://avatars.discourse-cdn.com/v4/letter/c/e79b87/32.png) [@CGavrila](https://discuss.elastic.co/u/CGavrila)\
**Post date:** [June 22, 2017, 7:52pm UTC](https://discuss.elastic.co/t/errors-when-using-spring-data-elasticsearch-version-3-0-0-build-snapshot-and-elasticsearch-5-4-0/90525/1 "2017-06-22T19:52:22Z")

</div>

I am trying to use Spring Data with Elasticsearch 5.4.0, but it seems like I cannot get it to work. I had a similar configuration that worked with ES 2.4.5, but it fails when I try to upgrade.

I cannot seem to get it working, and after days of trying to figure this out, I believe there may be something inherently wrong with the Spring Data elasticsearch library. I have also created a throwaway Python project trying to connect to my ES instance and that works fine.

I don't have enough characters available for the full stacktrace, but here is the error at the bottom:

```auto
Caused by: java.lang.NoClassDefFoundError: org/springframework/data/mapping/model/Property
	at java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.8.0_111]
	at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) ~[na:1.8.0_111]
	at java.lang.Class.getDeclaredMethods(Class.java:1975) ~[na:1.8.0_111]
	at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:613) ~[spring-core-4.3.6.RELEASE.jar:4.3.6.RELEASE]
	at org.springframework.util.ReflectionUtils.doWithLocalMethods(ReflectionUtils.java:489) ~[spring-core-4.3.6.RELEASE.jar:4.3.6.RELEASE]
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.buildLifecycleMetadata(InitDestroyAnnotationBeanPostProcessor.java:206) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.findLifecycleMetadata(InitDestroyAnnotationBeanPostProcessor.java:187) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(InitDestroyAnnotationBeanPostProcessor.java:125) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
	at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(CommonAnnotationBeanPostProcessor.java:295) ~[spring-context-4.3.6.RELEASE.jar:4.3.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:992) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:523) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
	... 72 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.springframework.data.mapping.model.Property
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_111]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_111]
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[na:1.8.0_111]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_111]
	... 83 common frames omitted

```

The Maven `pom.xml` file is largely:

```auto
<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
		<java.version>1.8</java.version>
		<elasticsearch.version>5.4.0</elasticsearch.version>
	</properties>

	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>
		<dependency>
			<groupId>com.rabbitmq</groupId>
			<artifactId>amqp-client</artifactId>
			<version>4.0.2</version>
		</dependency>
		<dependency>
			<groupId>org.projectlombok</groupId>
			<artifactId>lombok</artifactId>
			<optional>true</optional>
		</dependency>
		<dependency>
			<groupId>com.google.cloud</groupId>
			<artifactId>google-cloud-storage</artifactId>
			<version>1.0.2</version>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework.data</groupId>
			<artifactId>spring-data-elasticsearch</artifactId>
			<version>3.0.0.BUILD-SNAPSHOT</version>
		</dependency>
		<dependency>
			<groupId>org.apache.logging.log4j</groupId>
			<artifactId>log4j-api</artifactId>
			<version>2.8.2</version>
		</dependency>
		<dependency>
			<groupId>org.apache.logging.log4j</groupId>
			<artifactId>log4j-core</artifactId>
			<version>2.8.2</version>
		</dependency>
	</dependencies>

```

Spring configurations file:

```auto
@Configuration
@EnableElasticsearchRepositories(basePackages = "com.es.backend.repository")
public class EsConfig {

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

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

    @Value("${elasticsearch.cluster_name}")
    private String elasticsearchClusterName;

    @Bean
    public Client client() throws Exception {

        Settings esSettings = Settings.builder()
                .put("cluster.name", elasticsearchClusterName)
                .build();

        return new PreBuiltTransportClient(esSettings)
                .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(elasticsearchHost), elasticsearchPort));
    }

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

}

```

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 22, 2017, 10:23pm UTC](https://discuss.elastic.co/t/errors-when-using-spring-data-elasticsearch-version-3-0-0-build-snapshot-and-elasticsearch-5-4-0/90525/2 "2017-06-22T22:23:08Z")

</div>

IMO it's a spring question.

`org.springframework.data.mapping.model.Property` is missing in your classpath apparently.

Note that I don't know if spring-data-elasticsearch has been updated to elasticsearch 5.

---

<div class="post-metadata">

**Author:** ![CGavrila](https://avatars.discourse-cdn.com/v4/letter/c/e79b87/32.png) [@CGavrila](https://discuss.elastic.co/u/CGavrila)\
**Post date:** [June 22, 2017, 10:53pm UTC](https://discuss.elastic.co/t/errors-when-using-spring-data-elasticsearch-version-3-0-0-build-snapshot-and-elasticsearch-5-4-0/90525/3 "2017-06-22T22:53:58Z")

</div>

Thanks for the reply, David!

As far as I can tell from [the spring-data-elasticsearch Github page](https://github.com/spring-projects/spring-data-elasticsearch), it has been updated to ES 5.x.x.

As for this being a Spring question, it's my fault that I did not include a larger chunk of the stacktrace. Here's a slightly larger piece of it. The error is coming from `elasticsearchTemplate`, so that would be something internal in the elasticsearch libraries.

```auto
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'elasticsearchTemplate' defined in class path resource [org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchDataAutoConfiguration.class]: Post-processing of merged bean definition failed; nested exception is java.lang.NoClassDefFoundError: org/springframework/data/mapping/model/Property
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:526) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
	... 38 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/springframework/data/mapping/model/Property
	at java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.8.0_111]
	at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) ~[na:1.8.0_111]
	at java.lang.Class.getDeclaredMethods(Class.java:1975) ~[na:1.8.0_111]
	at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:613) ~[spring-core-4.3.6.RELEASE.jar:4.3.6.RELEASE]
	at org.springframework.util.ReflectionUtils.doWithLocalMethods(ReflectionUtils.java:489) ~[spring-core-4.3.6.RELEASE.jar:4.3.6.RELEASE]
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.buildLifecycleMetadata(InitDestroyAnnotationBeanPostProcessor.java:206) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.findLifecycleMetadata(InitDestroyAnnotationBeanPostProcessor.java:187) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(InitDestroyAnnotationBeanPostProcessor.java:125) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
	at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(CommonAnnotationBeanPostProcessor.java:295) ~[spring-context-4.3.6.RELEASE.jar:4.3.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:992) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:523) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
	... 72 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.springframework.data.mapping.model.Property
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_111]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_111]
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[na:1.8.0_111]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_111]
	... 83 common frames omitted

```

There are some examples of how to work with spring-data-elasticsearch on Github, but they are all 2-3 years old and none of them cover 5.x.x. If there is any chance that someone from the team, or anyone really, could provide a very simple example of how this is supposed to work, that would be awesome.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 22, 2017, 11:06pm UTC](https://discuss.elastic.co/t/errors-when-using-spring-data-elasticsearch-version-3-0-0-build-snapshot-and-elasticsearch-5-4-0/90525/4 "2017-06-22T23:06:23Z")

</div>

I don't see anything in the stacktrace related to `org.elasticsearch`. Do I miss something?

---

<div class="post-metadata">

**Author:** ![CGavrila](https://avatars.discourse-cdn.com/v4/letter/c/e79b87/32.png) [@CGavrila](https://discuss.elastic.co/u/CGavrila)\
**Post date:** [June 25, 2017, 7:19pm UTC](https://discuss.elastic.co/t/errors-when-using-spring-data-elasticsearch-version-3-0-0-build-snapshot-and-elasticsearch-5-4-0/90525/5 "2017-06-25T19:19:10Z")

</div>

Sorry it took some time to respond, I've been away.

You are correct, there is no direct reference to `org.elasticsearch` anywhere in the stacktrace. However, there seems to be a problem with the Elasticsearch Spring Data package, albeit on the Spring side of things. The only thing I can think of is that the Spring Data dependencies in the `spring-data-elasticsearch@3.0.0.BUILD-SNAPSHOT` package are not the correct ones.

I have created a very small, bare-bones Github repo that reproduces the problem - [https://github.com/CGavrila/spring-data-elasticsearch](https://github.com/CGavrila/spring-data-elasticsearch). There is also a full stacktrace in the repo's README.

It is also possible that I am doing something wrong in my `Entity`, but there really doesn't seem to be any documentation out there containing hints as to what might be wrong.

I know you don't have time to look at every single problem, but in this case, it looks like a genuine problem with the Spring integration.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 12, 2017, 9:03am UTC](https://discuss.elastic.co/t/errors-when-using-spring-data-elasticsearch-version-3-0-0-build-snapshot-and-elasticsearch-5-4-0/90525/6 "2017-07-12T09:03:04Z")

</div>

I'm afraid I don't have the answer. To me it's more something you should ask on the spring data mailing list.

BTW you are not alone:

> [@Startup error with springboot and elasticsearch 5.4.1 ClassNotFoundException: org.elasticsearch.action.count.CountRequestBuilder](https://discuss.elastic.co/t/startup-error-with-springboot-and-elasticsearch-5-4-1-classnotfoundexception-org-elasticsearch-action-count-countrequestbuilder/90482):
>
> i'm new to es,it errors when i start up my app with springboot .here are my settings: @Bean public Client client() throws Exception { Settings esSettings = Settings.builder() .put("cluster.name", EsClusterName) .put("client.transport.sniff", true) .build(); return new PreBuiltTransportClient(esSettings).addTransportAddresses(new InetSocketTransportAddress(InetAddress.getByName(EsHost), EsPort)); } error msg: org.springframework.beans.factory.BeanCreationException: Error creat…

I'm planning to play around Spring Data ES integration this summer but for now I have little experience with it (well almost no experience).

Anyway, thanks a lot for the full repository example. I know it's a lot of efforts doing so.

---

<div class="post-metadata">

**Author:** ![CGavrila](https://avatars.discourse-cdn.com/v4/letter/c/e79b87/32.png) [@CGavrila](https://discuss.elastic.co/u/CGavrila)\
**Post date:** [July 12, 2017, 9:31am UTC](https://discuss.elastic.co/t/errors-when-using-spring-data-elasticsearch-version-3-0-0-build-snapshot-and-elasticsearch-5-4-0/90525/7 "2017-07-12T09:31:25Z")

</div>

Yeah, no worries, I realize you can't just spend time helping everyone individually, so no worries. I've just settled for ES 2.4.x for the moment, will retry with 5.x.x when I get this fixed somehow.

Thanks for the help!

---

<div class="post-metadata">

**Author:** ![soarhu](https://avatars.discourse-cdn.com/v4/letter/s/aca169/32.png) [@soarhu](https://discuss.elastic.co/u/soarhu)\
**Post date:** [July 17, 2017, 2:07pm UTC](https://discuss.elastic.co/t/errors-when-using-spring-data-elasticsearch-version-3-0-0-build-snapshot-and-elasticsearch-5-4-0/90525/8 "2017-07-17T14:07:01Z")

</div>

yeah i used to meet the same question as u, but i remove the spring-data then it works.just use transport api is better

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 14, 2017, 2:07pm UTC](https://discuss.elastic.co/t/errors-when-using-spring-data-elasticsearch-version-3-0-0-build-snapshot-and-elasticsearch-5-4-0/90525/9 "2017-08-14T14:07:03Z")

</div>

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