Errors caused by not having declared a dependency

609 Views Asked by At

Has anyone successfully got Spring Boot, Spring Data Elasticsearch, and Elasticsearch 5.x to work?

I updated my pom to use spring-data-elasticsearch 3.0.0.RELEASE (just released) which has commit notes in Github saying it supports ES 5.

I was getting some errors which were caused by not having declared a dependency on spring-data-common. After adding without a version, I noticed it was being managed by Spring Boot apparently and pulls in 1.13.7.RELEASE

This causes: java.lang.NoClassDefFoundError: org/springframework/data/mapping/model/Property

I then bumped up spring-data-common to 2.0.0.RELEASE thinking the newest releases of everything should be compatible. That causes an AbstractMethodError exception when the repository is wired.

Can anyone give any tips? Here are the dependencies from my POM

Managed versions from Parent POM:
    <spring-boot.version>1.5.7.RELEASE</spring-boot.version>
    <spring-cloud.version>Dalston.RELEASE</spring-cloud.version>

From POM from the child module where things don't work

<dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-config</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
        </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-commons</artifactId>
<!--            <version>2.0.0.RELEASE</version> -->
        </dependency>

        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-elasticsearch</artifactId>
            <version>3.0.0.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.elasticsearch</groupId>
            <artifactId>elasticsearch</artifactId>
            <version>5.5.0</version>
        </dependency>

        <dependency>
                <groupId>org.elasticsearch.client</groupId>
                <artifactId>transport</artifactId>
             <version>5.5.0</version>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>

        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
        </dependency>

    </dependencies>
3

There are 3 best solutions below

0
On BEST ANSWER

Whomever edited the title made an inaccurate description. As originally stated, the issue is a "dependency hell". There wasn't missing dependencies but rather a ton of transitive dependencies that all needed versions to be coordinated in magic nonobvious/undocumented ways. – JvmSd121

0
On

You guys put me on the right track. I upgraded as follows:

Spring Core (and related): 5.0.0.RELEASE Spring Boot: 2.0.0.M4 Spring Cloud: Finchley.M2

With those in place, the managed versions get updated as follows:

spring-data-commons: 2.0.0.RC3 (from release-train KAY-RC3) spring-data-elasticsearch: 3.0.0.RC3 (from release-train KAY-RC3) elasticsearch and transport: 5.5.2 (meets my 5.x requirement)

We had managed versions of Jackson in our parent pom for other child modules which caused incompatible versions to be pulled in. I overrode those in our Spring Boot projects to the version ${jackson.version} defined in Spring as follows:

    spring-jackson-version=2.9.1

    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-annotations</artifactId>
        <version>${spring-jackson.version}</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-core</artifactId>
        <version>${spring-jackson.version}</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>${spring-jackson.version}</version>
    </dependency>

I'm getting another error from my repo which I think is self-inflicted due to my data model. All the classpath errors seem to have gone away. I'll give another update if I find anything further. What a cf!

Thanks for the tips.

0
On

I once migrated the spring-data-elasticsearch (with ES 2.x) project to use ES 5.x.

I lost the source but I still have the jar here