I got a "Whitelabel Error Page" when using Eureka server
Asked Answered
T

10

5

I created a spring cloud project using SPRING INITIALIZR. My project structure is as below: enter image description here

The DemoApplication:

package com.example.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;

@SpringBootApplication
@EnableEurekaServer
public class DemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }
}

application.properties:

server.port=8888
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
eureka.instance.hostname=localhost
eureka.client.service-url.defaultZone=localhost:8888/eureka
spring.application.name=appName

pom.xml:

<?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.example</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>demo</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.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>
        <spring-cloud.version>Greenwich.M3</spring-cloud.version>
    </properties>

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

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

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</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>

    <repositories>
        <repository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>https://repo.spring.io/milestone</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>
</project>

But when I visit localhost:8888, the following error occurs:

Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback.

Sun Dec 02 11:23:36 CST 2018 There was an unexpected error (type=Not Found, status=404). No message available

I don't konw why this happens.How can I solve this?

Trevor answered 2/12, 2018 at 3:39 Comment(0)
N
8

at-least the latest version of SpringBoot and Cloud requires these configs for Eureka UI to come up:

#in application.yml
spring:
  freemarker:
    template-loader-path: classpath:/templates/
    prefer-file-system-access: false

or

#in application.properties
spring.freemarker.template-loader-path= classpath:/templates/
spring.freemarker.prefer-file-system-access= false

See here: https://cloud.spring.io/spring-cloud-static/spring-cloud-netflix/2.1.0.RELEASE/multi/multi_spring-cloud-eureka-server.html#netflix-eureka-server-starter

Nonconductor answered 30/9, 2019 at 13:27 Comment(0)
S
5

For me, I have generated the project using start.spring.io and I have chosen Eureka Server, I did not know that I need to add @EnableEurekaServer myself on top of the application. It worked by adding that.

Spherule answered 29/1, 2021 at 9:37 Comment(0)
P
1

I had the same problem when using Greenwich.M3 spring cloud version. For me it worked when changing the spring cloud version to Finchley.SR1

<spring-cloud.version>Finchley.SR1</spring-cloud.version>
Pringle answered 3/12, 2018 at 15:23 Comment(0)
R
1

I use spring boot 2.2.1, spring cloud version Hoxton.RELEASE ( <spring-cloud.version>Hoxton.RELEASE</spring-cloud.version>),my settings is:

spring.application.name=testserver    
server.port=8888

eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
eureka.instance.hostname=localhost

eureka.client.serviceUrl.defaultZone=http://${eureka.instance.hostname}:${server.port}/eureka/

And for me url is http://localhost:8888/ (not http://localhost:8888/eureka).

For server, url depends on server.port and server.servlet.context-path properties (so, if i set server.servlet.context-path=/eureka, url will be http://localhost:8888/eureka)

Resnatron answered 5/12, 2019 at 13:26 Comment(0)
T
1

I am using spring boot 3.0.2 and spring cloud 2022.0.0. There is no need to specify EnableEurekaClient annotation anymore. The spring-cloud-starter-netflix-eureka-client dependency needs to be added for services.

Tonyatonye answered 7/2, 2023 at 17:56 Comment(0)
I
0

this is working for me:

application.properties file:

server.port=8888
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
eureka.instance.hostname=localhost
eureka.client.service-url.defaultZone=http://localhost:8888/eureka
spring.application.name=appName

pom.xml:

<?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.example</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>demo</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.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>
        <spring-cloud.version>Greenwich.M3</spring-cloud.version>
    </properties>

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

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

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</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>

    <repositories>
        <repository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>https://repo.spring.io/milestone</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>


</project>

visit : localhost:8888

Incomprehensible answered 2/12, 2018 at 4:7 Comment(5)
eureka.client.service-url.defaultZone=localhost:8888/eureka add this to your property file and check againIncomprehensible
i think it will work. don't forget to name your application name in property fileIncomprehensible
spring.application.name=appNameIncomprehensible
It is still notTrevor
You can try these in your system. I don't konw why it is not workingTrevor
N
0

I am using springboot 3.0.0 version and java 17. These versions are not working together stable. I tried to all the suggestions above but it did not work in my case. I finally found solution for my own case.

It started appearing, when I changed the jdk version from "eclipse temurin jdk 17 version" to "open jdk 19".

Edit: 

After the solution, on the client side, I cannot register my service to Eureka service. When I change the spring version as "2.7.5", it works.

Neurology answered 3/12, 2022 at 0:15 Comment(0)
G
0

I had to do following:

  • Upgrade maven to 3.8.8 (had 3.8.4 which couldnt resolve Eureka server dependency)
  • Make sure to include Eureka Server, Eureka Client, Spring Web dependencies
  • Modify main application class and annotate with @EnableEurekaServer

Then http://localhost:8761 worked!

Godbeare answered 29/3, 2023 at 8:13 Comment(0)
M
0

I got the same issue "white label error page" .As i was using older version of spring cloud (2021.0.3) with java 17 and spring boot i have used 3.2.x .I had updated the version of spring cloud as 2023.0.3 the issue got resolved.

Mckenziemckeon answered 28/7 at 14:43 Comment(0)
A
0

I was using http://localhost:8761/eureka/ which was printed in the Springboot startup console then I was getting the error "Whitelabel Error Page This application has no explicit mapping for /error" enter image description here

After removing the eureka/ from the ULR it worked. working URL: http://localhost:8761/

Note: I have to define server.port=8761 in the application explicitly.properties file

Acetate answered 10/10 at 6:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.