11

In this coding exercise for learning microservices, I've created a Netflix Zuul project for service routing my microservices.

Sadly, the /routes endpoint does not seem to be mounted. Everything else seems to be working fine: Defining prefixes and setting up specific routes for my services.

There are no errors on the zuul server log files. When I try to hit the /routes url on postman, I get an 404 error: Zuul Routes not returning anything

My Zuul application class:

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;

@SpringBootApplication
@EnableZuulProxy
public class ZuulServerApplication {
    public static void main(String[] args) {
        SpringApplication.run(ZuulServerApplication.class, args);
    }
}

pom.xml file:

<?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/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion> <!--should be set to 4.0.0 -->
    <groupId>com.booking.system.hotel</groupId>
    <version>0.0.1-SNAPSHOT</version>
    <artifactId>hotel-gateway-service-server</artifactId>

    <name>Hotel Gateway service - zuul</name>
    <description>Hotel Gateway service - it uses Netflix Zuul Proxy Server</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.5.RELEASE</version>
    </parent>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Finchley.RELEASE</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>1.8</java.version>
        <start-class>com.booking.system.hotel.zuulsvr.ZuulServerApplication</start-class>
    </properties>
    <dependencies>

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-zuul</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-config</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-config-client</artifactId>
        </dependency>
    </dependencies>

    <build>
    <finalName>hotel-gateway-service-server</finalName> <!--name of the jar -->
        <plugins>
            <!-- packages the project as an executable jar, as an Spring Boot application -->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <!-- used for running tests at various stages -->
        </plugins>
    </build>
</project>

bootstrap.yml file:

spring:
  application:
    name: hotel-gateway-service-server
  profiles:
    active:
      default
  cloud:
    config:
      enabled: true

Zuul configuration file from configuration server:

zuul.ignored-services: "*"
zuul.prefix:  /api
zuul.routes.hotel-reservations-service: /reservations/**
zuul.routes.hotel-rooms-service: /rooms/**

docker-compose.yml entry for initializing the zuul gateway server:

   hotel-gateway-service-server: #zuul server
      image: imageprefix/hotel-gateway-service-server
      ports:
         - 5555:5555
      environment:
         PROFILE: "dev"
         SERVER_PORT: "5555" 
         CONFIGSERVER_URI: "http://hotel-configuration-server:8888"
         CONFIGSERVER_PORT: "8888"
         EUREKASERVER_URI: "http://hotel-service-discovery-server:8761/eureka/"
         EUREKASERVER_PORT: "8761"

I don't seem to spot what I am missing.

Lucas T
  • 3,011
  • 6
  • 29
  • 36
  • It seems that the route URL is http://localhost:5555 and /routes is not defined. Did you try that ? – Aarish Ramesh Sep 19 '18 at 09:42
  • Thanks, @AarishRamesh. I tried hitting http://localhost:5555/ on postman and I get the same error. The zuul server works fine when I call other webservices via zuul, for example: http://localhost:5555/api/reservations/v1/hotels/hotel01/reservations/room01 – Lucas T Sep 19 '18 at 09:49
  • Could you please try to call private-intmon/routes instead of routes? – staszko032 Sep 19 '18 at 09:59
  • Thanks, @staszko032. I called http://localhost:5555/private-intmon/routes and I get the same "status": 404, "error": "Not Found" result. – Lucas T Sep 19 '18 at 10:05
  • I think you are checking at the wrong port. Can you check the edge server default port and check /routes on that ? or can you define server.port=8080 in your bootstrap.yml ? – Aarish Ramesh Sep 19 '18 at 10:11
  • Thank you, @AarishRamesh. On my src/main/resources/application.yml, I have set the following property server: port: 5555. Also, on my docker-compose.yml file, I have hotel-gateway-service-server: #zuul server image: imageprefix/hotel-gateway-service-server ports: - 5555:5555 – Lucas T Sep 19 '18 at 10:14
  • According to documentation - /routes endpoint comes from actuator so please add: org.springframework.boot spring-boot-starter-actuator – staszko032 Sep 19 '18 at 10:14
  • Thank you, @staszko032. I've added the dependency to my pom file. But I still get the same "status": 404, "error": "Not Found" result. – Lucas T Sep 19 '18 at 10:23
  • 1
    Could you please post your zuul configuration (I mean file with routes defined)? – staszko032 Sep 19 '18 at 10:33
  • Thank you, @staszko032. I've updated my post to include configuration file reference and docker compose entry. – Lucas T Sep 19 '18 at 11:03

1 Answers1

20

The actuator base path has changed to /actuator. So you need to use /actuator/routes. It is also not enabled by default.

management.endpoints.web.exposure.include=*
spencergibb
  • 24,471
  • 6
  • 69
  • 75
  • 1
    Thank you, @spencergibb. I've added that to the config file, on the config repo and it works like a charm. Also, I noticed that when running http://localhost:5555/actuator there are numerous new URLS. =0) – Lucas T Sep 20 '18 at 13:13
  • 1
    Also, relevant post: https://stackoverflow.com/questions/50114501/actuator-refresh-is-not-being-provided-in-springboot-2-0-1 – Lucas T Sep 21 '18 at 07:02
  • Thank you @spencerbigg. In case someone could need this in YML (as I did): https://stackoverflow.com/a/48901161/4975667 – Francisco Acevedo Mar 11 '22 at 11:22