0

I have created a spring boot application to register my application in Eureka Service named 'eureka-service'. While running the application it is throwing error. I am using the boot version '2.0.1' here is the stack trace:

java.lang.NoClassDefFoundError: org/springframework/boot/bind/RelaxedDataBinder
  at org.springframework.cloud.client.HostInfoEnvironmentPostProcessor.getFirstNonLoopbackHostInfo(HostInfoEnvironmentPostProcessor.java:45)
  at org.springframework.cloud.client.HostInfoEnvironmentPostProcessor.postProcessEnvironment(HostInfoEnvironmentPostProcessor.java:34)
  at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEnvironmentPreparedEvent(ConfigFileApplicationListener.java:183)
  at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEvent(ConfigFileApplicationListener.java:169)
  at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
  at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
  at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
  at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)
  at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:74)
  at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
  at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:358)
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:317)
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255)
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243)
  at com.rest.EurekaServerApplication.main(EurekaServerApplication.java:12)

Caused by: java.lang.ClassNotFoundException: org.springframework.boot.bind.RelaxedDataBinder
  at java.net.URLClassLoader.findClass(Unknown Source)
  at java.lang.ClassLoader.loadClass(Unknown Source)
  at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
  at java.lang.ClassLoader.loadClass(Unknown Source)
  ... 15 common frames omitted

Below is the pom.xml that i have used:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.rest</groupId>
<artifactId>Eureka-server</artifactId>
<version>0.0.1</version>
<packaging>jar</packaging>

<name>Eureka-server</name>
<description>Demo project for Spring Boot</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.1.RELEASE</version>
    <relativePath /> <!-- lookup parent from repository -->
</parent>

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

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-eureka-server</artifactId>
    </dependency>
</dependencies>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>Camden.SR6</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

I tried searching for an answer but those options are not working for me.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Vishnu
  • 176
  • 1
  • 2
  • 19

1 Answers1

0

Should not mix Spring Boot 2.x with Spring Cloud Edgware or earlier (Dalston, Camden, ...).

Spring Boot 2.0.x should be used with Spring Cloud Finchley which is not GA yet, it's RC1 as of 05/02/2018.

https://github.com/spring-projects/spring-cloud/wiki/Spring-Cloud-Finchley-Release-Notes

https://github.com/spring-projects/spring-cloud/wiki/Spring-Cloud-Camden-Release-Notes

ootero
  • 3,235
  • 2
  • 16
  • 22