Unable to find GatewayFilterFactory with name CircuitBreaker
Asked Answered
A

11

10

Properties File

server:
  port: 8999
  
eureka:
  instance:
    hostname: localhost

    
#Actuator Configuration
management:
  endpoints:
    web:
      exposure:
        include: hystrix.stream, health, info  
        
#Hystrix Configuration
hystrix:
  command:
    fallbackcmd:
      execution:
        isolation:
          thread:
            timeoutInMilliseconds: 4000


spring:
  application:
    name: gateway
  cloud:
    gateway:
      routes:
      - id: capability-deck
        uri: lb://capability-deck
        predicates:
        - Path=/capability/**
        filters:
            - name: CircuitBreaker
              args:
                name: capability-deck
                fallbackuri: forward:/capabilityServiceFallBack
        
     
      - id: home-page
        uri: lb://home-page
        predicates:
        - Path=/home/**
      
        
      - id: subscription
        uri: lb://subscription
        predicates:
        - Path=/subscription/**
       
       
        

Controller

package com.valuepedia.gateway.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class FallBackController {

    @GetMapping("/subscriptionServiceFallBack")
    public String userServiceFallBackMethod() {
        return "Subscription Service is taking longer than Expected." +
                " Please try again later";
    }

    @GetMapping("/capabilityServiceFallBack")
    public String capabilityServiceFallBackMethod() {
        return "Capability Service is taking longer than Expected." +
                " Please try again later";
    }
    
    @GetMapping("/homeServiceFallBack")
    public String homeServiceFallBackMethod() {
        return "Home Service is taking longer than Expected." +
                " Please try again later";
    }
}

Main Class

package com.valuepedia.gateway;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
@EnableEurekaClient
@EnableHystrix
public class GatewayApplication {

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

Getting error message as


  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
[32m :: Spring Boot :: [39m              [2m (v2.5.4)[0;39m

[2m2021-09-21 09:44:08.705[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mc.valuepedia.gateway.GatewayApplication [0;39m [2m:[0;39m Starting GatewayApplication using Java 15.0.2 on A2568L with PID 7852 (D:\Valuepedia\Gateway\target\classes started by Swapnil.Soni in D:\Valuepedia\Gateway)
[2m2021-09-21 09:44:08.714[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mc.valuepedia.gateway.GatewayApplication [0;39m [2m:[0;39m No active profile set, falling back to default profiles: default
[2m2021-09-21 09:44:10.561[0;39m [33m WARN[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.s.boot.actuate.endpoint.EndpointId    [0;39m [2m:[0;39m Endpoint ID 'hystrix.stream' contains invalid characters, please migrate to a valid format.
[2m2021-09-21 09:44:13.646[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.s.cloud.context.scope.GenericScope    [0;39m [2m:[0;39m BeanFactory id=86068429-c6fe-399f-b31b-17fdee65f911
[2m2021-09-21 09:44:14.693[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mtrationDelegate$BeanPostProcessorChecker[0;39m [2m:[0;39m Bean 'org.springframework.cloud.client.loadbalancer.reactive.LoadBalancerBeanPostProcessorAutoConfiguration' of type [org.springframework.cloud.client.loadbalancer.reactive.LoadBalancerBeanPostProcessorAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[2m2021-09-21 09:44:14.697[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mtrationDelegate$BeanPostProcessorChecker[0;39m [2m:[0;39m Bean 'org.springframework.cloud.client.loadbalancer.reactive.LoadBalancerBeanPostProcessorAutoConfiguration$ReactorDeferringLoadBalancerFilterConfig' of type [org.springframework.cloud.client.loadbalancer.reactive.LoadBalancerBeanPostProcessorAutoConfiguration$ReactorDeferringLoadBalancerFilterConfig] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[2m2021-09-21 09:44:14.701[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mtrationDelegate$BeanPostProcessorChecker[0;39m [2m:[0;39m Bean 'reactorDeferringLoadBalancerExchangeFilterFunction' of type [org.springframework.cloud.client.loadbalancer.reactive.DeferringLoadBalancerExchangeFilterFunction] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[2m2021-09-21 09:44:15.438[0;39m [33m WARN[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mc.n.c.sources.URLConfigurationSource    [0;39m [2m:[0;39m No URLs will be polled as dynamic configuration sources.
[2m2021-09-21 09:44:15.440[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mc.n.c.sources.URLConfigurationSource    [0;39m [2m:[0;39m To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
[2m2021-09-21 09:44:15.463[0;39m [33m WARN[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mc.n.c.sources.URLConfigurationSource    [0;39m [2m:[0;39m No URLs will be polled as dynamic configuration sources.
[2m2021-09-21 09:44:15.463[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mc.n.c.sources.URLConfigurationSource    [0;39m [2m:[0;39m To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
[2m2021-09-21 09:44:19.020[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.s.c.g.r.RouteDefinitionRouteLocator   [0;39m [2m:[0;39m Loaded RoutePredicateFactory [After]
[2m2021-09-21 09:44:19.021[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.s.c.g.r.RouteDefinitionRouteLocator   [0;39m [2m:[0;39m Loaded RoutePredicateFactory [Before]
[2m2021-09-21 09:44:19.021[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.s.c.g.r.RouteDefinitionRouteLocator   [0;39m [2m:[0;39m Loaded RoutePredicateFactory [Between]
[2m2021-09-21 09:44:19.021[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.s.c.g.r.RouteDefinitionRouteLocator   [0;39m [2m:[0;39m Loaded RoutePredicateFactory [Cookie]
[2m2021-09-21 09:44:19.022[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.s.c.g.r.RouteDefinitionRouteLocator   [0;39m [2m:[0;39m Loaded RoutePredicateFactory [Header]
[2m2021-09-21 09:44:19.022[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.s.c.g.r.RouteDefinitionRouteLocator   [0;39m [2m:[0;39m Loaded RoutePredicateFactory [Host]
[2m2021-09-21 09:44:19.022[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.s.c.g.r.RouteDefinitionRouteLocator   [0;39m [2m:[0;39m Loaded RoutePredicateFactory [Method]
[2m2021-09-21 09:44:19.023[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.s.c.g.r.RouteDefinitionRouteLocator   [0;39m [2m:[0;39m Loaded RoutePredicateFactory [Path]
[2m2021-09-21 09:44:19.025[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.s.c.g.r.RouteDefinitionRouteLocator   [0;39m [2m:[0;39m Loaded RoutePredicateFactory [Query]
[2m2021-09-21 09:44:19.026[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.s.c.g.r.RouteDefinitionRouteLocator   [0;39m [2m:[0;39m Loaded RoutePredicateFactory [ReadBody]
[2m2021-09-21 09:44:19.027[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.s.c.g.r.RouteDefinitionRouteLocator   [0;39m [2m:[0;39m Loaded RoutePredicateFactory [RemoteAddr]
[2m2021-09-21 09:44:19.027[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.s.c.g.r.RouteDefinitionRouteLocator   [0;39m [2m:[0;39m Loaded RoutePredicateFactory [Weight]
[2m2021-09-21 09:44:19.027[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.s.c.g.r.RouteDefinitionRouteLocator   [0;39m [2m:[0;39m Loaded RoutePredicateFactory [CloudFoundryRouteService]
[2m2021-09-21 09:44:21.669[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.s.b.a.e.web.EndpointLinksResolver     [0;39m [2m:[0;39m Exposing 3 endpoint(s) beneath base path '/actuator'
[2m2021-09-21 09:44:22.230[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mDiscoveryClientOptionalArgsConfiguration[0;39m [2m:[0;39m Eureka HTTP Client uses RestTemplate.
[2m2021-09-21 09:44:22.424[0;39m [33m WARN[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36miguration$LoadBalancerCaffeineWarnLogger[0;39m [2m:[0;39m Spring Cloud LoadBalancer is currently working with the default cache. You can switch to using Caffeine cache, by adding it and org.springframework.cache.caffeine.CaffeineCacheManager to the classpath.
[2m2021-09-21 09:44:22.611[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.s.c.n.eureka.InstanceInfoFactory      [0;39m [2m:[0;39m Setting initial instance status as: STARTING
[2m2021-09-21 09:44:22.800[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mcom.netflix.discovery.DiscoveryClient   [0;39m [2m:[0;39m Initializing Eureka in region us-east-1
[2m2021-09-21 09:44:22.820[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mc.n.d.s.r.aws.ConfigClusterResolver     [0;39m [2m:[0;39m Resolving eureka endpoints via configuration
[2m2021-09-21 09:44:22.919[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mcom.netflix.discovery.DiscoveryClient   [0;39m [2m:[0;39m Disable delta property : false
[2m2021-09-21 09:44:22.919[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mcom.netflix.discovery.DiscoveryClient   [0;39m [2m:[0;39m Single vip registry refresh property : null
[2m2021-09-21 09:44:22.919[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mcom.netflix.discovery.DiscoveryClient   [0;39m [2m:[0;39m Force full registry fetch : false
[2m2021-09-21 09:44:22.920[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mcom.netflix.discovery.DiscoveryClient   [0;39m [2m:[0;39m Application is null : false
[2m2021-09-21 09:44:22.920[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mcom.netflix.discovery.DiscoveryClient   [0;39m [2m:[0;39m Registered Applications size is zero : true
[2m2021-09-21 09:44:22.920[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mcom.netflix.discovery.DiscoveryClient   [0;39m [2m:[0;39m Application version is -1: true
[2m2021-09-21 09:44:22.920[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mcom.netflix.discovery.DiscoveryClient   [0;39m [2m:[0;39m Getting all instance registry info from the eureka server
[2m2021-09-21 09:44:24.054[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mcom.netflix.discovery.DiscoveryClient   [0;39m [2m:[0;39m The response status is 200
[2m2021-09-21 09:44:24.067[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mcom.netflix.discovery.DiscoveryClient   [0;39m [2m:[0;39m Starting heartbeat executor: renew interval is: 30
[2m2021-09-21 09:44:24.081[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mc.n.discovery.InstanceInfoReplicator    [0;39m [2m:[0;39m InstanceInfoReplicator onDemand update allowed rate per min is 4
[2m2021-09-21 09:44:24.119[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mcom.netflix.discovery.DiscoveryClient   [0;39m [2m:[0;39m Discovery Client initialized at timestamp 1632197664116 with initial instances count: 0
[2m2021-09-21 09:44:24.126[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.s.c.n.e.s.EurekaServiceRegistry       [0;39m [2m:[0;39m Registering application GATEWAY with eureka with status UP
[2m2021-09-21 09:44:24.127[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mcom.netflix.discovery.DiscoveryClient   [0;39m [2m:[0;39m Saw local status change event StatusChangeEvent [timestamp=1632197664127, current=UP, previous=STARTING]
[2m2021-09-21 09:44:24.131[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[nfoReplicator-0][0;39m [36mcom.netflix.discovery.DiscoveryClient   [0;39m [2m:[0;39m DiscoveryClient_GATEWAY/A2568L.corp.ads.valuelabs.net:gateway:8999: registering service...
[2m2021-09-21 09:44:24.201[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[nfoReplicator-0][0;39m [36mcom.netflix.discovery.DiscoveryClient   [0;39m [2m:[0;39m DiscoveryClient_GATEWAY/A2568L.corp.ads.valuelabs.net:gateway:8999 - registration status: 204
[2m2021-09-21 09:44:24.270[0;39m [31mERROR[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.s.c.gateway.route.CachingRouteLocator [0;39m [2m:[0;39m Refresh routes error !!!

java.lang.IllegalArgumentException: Unable to find GatewayFilterFactory with name CircuitBreaker
    at org.springframework.cloud.gateway.route.RouteDefinitionRouteLocator.loadGatewayFilters(RouteDefinitionRouteLocator.java:130) ~[spring-cloud-gateway-server-3.0.3.jar:3.0.3]
    at org.springframework.cloud.gateway.route.RouteDefinitionRouteLocator.getFilters(RouteDefinitionRouteLocator.java:176) ~[spring-cloud-gateway-server-3.0.3.jar:3.0.3]
    at org.springframework.cloud.gateway.route.RouteDefinitionRouteLocator.convertToRoute(RouteDefinitionRouteLocator.java:117) ~[spring-cloud-gateway-server-3.0.3.jar:3.0.3]
    at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:106) ~[reactor-core-3.4.9.jar:3.4.9]
    at reactor.core.publisher.FluxFlatMap$FlatMapMain.tryEmitScalar(FluxFlatMap.java:488) ~[reactor-core-3.4.9.jar:3.4.9]
    at reactor.core.publisher.FluxFlatMap$FlatMapMain.onNext(FluxFlatMap.java:421) ~[reactor-core-3.4.9.jar:3.4.9]
    at reactor.core.publisher.FluxMergeSequential$MergeSequentialMain.drain(FluxMergeSequential.java:432) ~[reactor-core-3.4.9.jar:3.4.9]
    at reactor.core.publisher.FluxMergeSequential$MergeSequentialMain.innerComplete(FluxMergeSequential.java:328) ~[reactor-core-3.4.9.jar:3.4.9]
    at reactor.core.publisher.FluxMergeSequential$MergeSequentialInner.onSubscribe(FluxMergeSequential.java:552) ~[reactor-core-3.4.9.jar:3.4.9]
    at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:164) ~[reactor-core-3.4.9.jar:3.4.9]
    at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:86) ~[reactor-core-3.4.9.jar:3.4.9]
    at reactor.core.publisher.Flux.subscribe(Flux.java:8411) ~[reactor-core-3.4.9.jar:3.4.9]
    at reactor.core.publisher.FluxMergeSequential$MergeSequentialMain.onNext(FluxMergeSequential.java:237) ~[reactor-core-3.4.9.jar:3.4.9]
    at reactor.core.publisher.FluxIterable$IterableSubscription.slowPath(FluxIterable.java:270) ~[reactor-core-3.4.9.jar:3.4.9]
    at reactor.core.publisher.FluxIterable$IterableSubscription.request(FluxIterable.java:228) ~[reactor-core-3.4.9.jar:3.4.9]
    at reactor.core.publisher.FluxMergeSequential$MergeSequentialMain.onSubscribe(FluxMergeSequential.java:198) ~[reactor-core-3.4.9.jar:3.4.9]
    at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:164) ~[reactor-core-3.4.9.jar:3.4.9]
    at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:86) ~[reactor-core-3.4.9.jar:3.4.9]
    at reactor.core.publisher.Flux.subscribe(Flux.java:8411) ~[reactor-core-3.4.9.jar:3.4.9]
    at reactor.core.publisher.FluxMergeSequential$MergeSequentialMain.onNext(FluxMergeSequential.java:237) ~[reactor-core-3.4.9.jar:3.4.9]
    at reactor.core.publisher.FluxIterable$IterableSubscription.slowPath(FluxIterable.java:270) ~[reactor-core-3.4.9.jar:3.4.9]
    at reactor.core.publisher.FluxIterable$IterableSubscription.request(FluxIterable.java:228) ~[reactor-core-3.4.9.jar:3.4.9]
    at reactor.core.publisher.FluxMergeSequential$MergeSequentialMain.onSubscribe(FluxMergeSequential.java:198) ~[reactor-core-3.4.9.jar:3.4.9]
    at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:164) ~[reactor-core-3.4.9.jar:3.4.9]
    at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:86) ~[reactor-core-3.4.9.jar:3.4.9]
    at reactor.core.publisher.Mono.subscribe(Mono.java:4338) ~[reactor-core-3.4.9.jar:3.4.9]
    at reactor.core.publisher.Mono.subscribeWith(Mono.java:4453) ~[reactor-core-3.4.9.jar:3.4.9]
    at reactor.core.publisher.Mono.subscribe(Mono.java:4309) ~[reactor-core-3.4.9.jar:3.4.9]
    at reactor.core.publisher.Mono.subscribe(Mono.java:4245) ~[reactor-core-3.4.9.jar:3.4.9]
    at reactor.core.publisher.Mono.subscribe(Mono.java:4217) ~[reactor-core-3.4.9.jar:3.4.9]
    at org.springframework.cloud.gateway.route.CachingRouteLocator.onApplicationEvent(CachingRouteLocator.java:81) ~[spring-cloud-gateway-server-3.0.3.jar:3.0.3]
    at org.springframework.cloud.gateway.route.CachingRouteLocator.onApplicationEvent(CachingRouteLocator.java:40) ~[spring-cloud-gateway-server-3.0.3.jar:3.0.3]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176) ~[spring-context-5.3.9.jar:5.3.9]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169) ~[spring-context-5.3.9.jar:5.3.9]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143) ~[spring-context-5.3.9.jar:5.3.9]
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:421) ~[spring-context-5.3.9.jar:5.3.9]
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:378) ~[spring-context-5.3.9.jar:5.3.9]
    at org.springframework.cloud.gateway.route.RouteRefreshListener.reset(RouteRefreshListener.java:73) ~[spring-cloud-gateway-server-3.0.3.jar:3.0.3]
    at org.springframework.cloud.gateway.route.RouteRefreshListener.onApplicationEvent(RouteRefreshListener.java:54) ~[spring-cloud-gateway-server-3.0.3.jar:3.0.3]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176) ~[spring-context-5.3.9.jar:5.3.9]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169) ~[spring-context-5.3.9.jar:5.3.9]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143) ~[spring-context-5.3.9.jar:5.3.9]
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:421) ~[spring-context-5.3.9.jar:5.3.9]
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:378) ~[spring-context-5.3.9.jar:5.3.9]
    at org.springframework.cloud.netflix.eureka.serviceregistry.EurekaAutoServiceRegistration.start(EurekaAutoServiceRegistration.java:85) ~[spring-cloud-netflix-eureka-client-3.0.3.jar:3.0.3]
    at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:178) ~[spring-context-5.3.9.jar:5.3.9]
    at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:54) ~[spring-context-5.3.9.jar:5.3.9]
    at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:356) ~[spring-context-5.3.9.jar:5.3.9]
    at java.base/java.lang.Iterable.forEach(Iterable.java:75) ~[na:na]
    at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:155) ~[spring-context-5.3.9.jar:5.3.9]
    at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:123) ~[spring-context-5.3.9.jar:5.3.9]
    at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:935) ~[spring-context-5.3.9.jar:5.3.9]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586) ~[spring-context-5.3.9.jar:5.3.9]
    at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:64) ~[spring-boot-2.5.4.jar:2.5.4]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) ~[spring-boot-2.5.4.jar:2.5.4]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434) ~[spring-boot-2.5.4.jar:2.5.4]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:338) ~[spring-boot-2.5.4.jar:2.5.4]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343) ~[spring-boot-2.5.4.jar:2.5.4]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1332) ~[spring-boot-2.5.4.jar:2.5.4]
    at com.valuepedia.gateway.GatewayApplication.main(GatewayApplication.java:15) ~[classes/:na]

[2m2021-09-21 09:44:24.290[0;39m [33m WARN[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36monfigReactiveWebServerApplicationContext[0;39m [2m:[0;39m Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean 'eurekaAutoServiceRegistration'; nested exception is java.lang.IllegalArgumentException: Unable to find GatewayFilterFactory with name CircuitBreaker
[2m2021-09-21 09:44:24.347[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mcom.netflix.discovery.DiscoveryClient   [0;39m [2m:[0;39m Shutting down DiscoveryClient ...
[2m2021-09-21 09:44:27.370[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mcom.netflix.discovery.DiscoveryClient   [0;39m [2m:[0;39m Unregistering ...
[2m2021-09-21 09:44:27.384[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mcom.netflix.discovery.DiscoveryClient   [0;39m [2m:[0;39m DiscoveryClient_GATEWAY/A2568L.corp.ads.valuelabs.net:gateway:8999 - deregister  status: 200
[2m2021-09-21 09:44:27.538[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mcom.netflix.discovery.DiscoveryClient   [0;39m [2m:[0;39m Completed shut down of DiscoveryClient
[2m2021-09-21 09:44:27.549[0;39m [32m INFO[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mConditionEvaluationReportLoggingListener[0;39m [2m:[0;39m 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
[2m2021-09-21 09:44:27.593[0;39m [31mERROR[0;39m [35m7852[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.s.boot.SpringApplication              [0;39m [2m:[0;39m Application run failed

org.springframework.context.ApplicationContextException: Failed to start bean 'eurekaAutoServiceRegistration'; nested exception is java.lang.IllegalArgumentException: Unable to find GatewayFilterFactory with name CircuitBreaker
    at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:181) ~[spring-context-5.3.9.jar:5.3.9]
    at 

When I am trying to run my Gateway application I am getting the following error I have also tried by changing version of spring cloud to Hoxton.SR7 but it is still not working. Please provide the solution for it. Also I have implemented the hystrix dashboard but is stuck in loading page only.

Antione answered 21/9, 2021 at 4:29 Comment(0)
C
19

Unlike what the docs https://cloud.spring.io/spring-cloud-gateway/reference/html/#spring-cloud-circuitbreaker-filter-factory says about:

To enable the Spring Cloud CircuitBreaker filter you will need to either place spring-cloud-starter-circuitbreaker-reactor-resilience4j or spring-cloud-starter-netflix-hystrix on the classpath.

One will need to have BOTH of the dependencies in order to have the auto configuration to configure the SpringCloudCircuitBreakerResilience4JFilterFactory bean.

ie. pom.xml:

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

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-circuitbreaker-reactor-resilience4j</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
    </dependency>
</dependencies>

It is due to this auto configuration class's code:

@ConditionalOnClass({ DispatcherHandler.class,
        ReactiveResilience4JAutoConfiguration.class,
        HystrixCircuitBreakerAutoConfiguration.class })
public class GatewayCircuitBreakerAutoConfiguration {
and @ConditionalOnClass's

javadocs says:

The classes that must be present.

Hence whatever listed as the list param to @ConditionalOnClass are in and relationship instead of what the docs claims to be or relationship.

Cowled answered 6/1, 2022 at 10:28 Comment(3)
Adding both resilience4j and hystrix actually worked for me. Thank you! – Kynan
same thing worked for me as well. Thank you! – Kenti
Adding the mentioned dependencies helped in resolving the issue. Thanks! – Fustanella
C
5

As per the docs for Spring Cloud CircuitBreaker GatewayFilter Factory

To enable the Spring Cloud CircuitBreaker filter you will need to either place spring-cloud-starter-circuitbreaker-reactor-resilience4j or spring-cloud-starter-netflix-hystrix on the classpath.

So, Try after adding below dependencies in your pom.xml file :

  1. spring-cloud-starter-gateway
  2. spring-cloud-starter-circuitbreaker-reactor-resilience4j
  3. spring-cloud-starter-netflix-hystrix
Creditable answered 21/9, 2021 at 5:1 Comment(0)
M
1

Check spring-boot version . I had the same problem . Spent a lot of time to find solution. Problem was resolved when a change the version of spring-boot in .pom file from 2.5.5 to 2.3.4 Release and spring-cloud.version from 2020.0.4 to Hoxton.SR8

version 2.5.5


enter image description here


enter image description here


enter image description here

Mackenie answered 14/10, 2021 at 20:33 Comment(0)
S
1

Adding these dependencies worked for me. I had to add

spring-cloud-starter-circuitbreaker-reactor-circuitbreaker

to my pom.xml

Saritasarkaria answered 27/1, 2022 at 7:59 Comment(0)
D
1

We need both spring-cloud-starter-circuitbreaker-reactor-resilience4j and spring-cloud-starter-netflix-hystrix for hystrix configuration Import the following dependencies

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
            <version>{new-version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-circuitbreaker-reactor-resilience4j</artifactId>
        </dependency>

FallBackController

@RestController
public class FallbackController {
@RequestMapping("/orderFallBack")
public Mono<String> orderServiceFallBack(){
    return Mono.just("Order Service is taking too long to respond or is down. Please try again later");
}
@RequestMapping("/paymentFallBack")
public Mono<String> paymentServiceFallBack(){
    return Mono.just("Payment Service is taking too long to respond or is down. Please try again later");
}
}

Main Application Class

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

application.properties

spring:
  application:
    name: GATEWAY-SERVICE
  cloud:
    gateway:
      routes:
        - id: order-service
          uri: lb://ORDER-SERVICE
          predicates:
            - Path=/order/**
          filters:
            - name: CircuitBreaker
              args:
                name: order-service
                fallbackuri: forward:/orderFallBack
        - id: payment-service
          uri: lb://PAYMENT-SERVICE
          predicates:
            - Path=/payment/**
          filters:
            - name: CircuitBreaker
              args:
                name: payment-service
                fallbackuri: forward:/paymentFallBack

server:
  port: 8989

eureka:
  client:
    fetch-registry: true
    register-with-eureka: true
    service-url:
      defaultZone: http://localhost:8761/eureka/
  instance:
    hostname: localhost
management:
  endpoints:
    web:
      exposure:
        include: hystrix.stream

hystrix:
  command:
    fallbackcmd:
      execution:
        isolation:
          thread:
            timeoutInMilliseconds: 5000

I hope this helps! Let me know if you have any questions or if there's anything else I can assist you with.

Happy coding! πŸ‘¨β€πŸ’»

Darwen answered 24/9, 2022 at 11:50 Comment(0)
A
1

Adding the following dependency in pom.xml worked for me

<dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-circuitbreaker-reactor- 
            resilience4j</artifactId>
</dependency>
Areola answered 2/2, 2023 at 7:37 Comment(1)
Only adding this wont worked for me after adding 'spring-cloud-starter-netflix-hystrix', it started working. – Illegible
D
1

To use Reactor in a Spring Boot project, you need to add the appropriate dependency for Reactor. You can include the Reactor dependency in your project by adding the following entry to your Maven 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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.3</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.fazaltuts4u</groupId>
    <artifactId>CloudGateway</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>CloudGateway</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>17</java.version>
        <spring-cloud.version>2021.0.7</spring-cloud.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-webflux</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-circuitbreaker-reactor-resilience4j</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-config</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-gateway</artifactId>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.projectreactor</groupId>
            <artifactId>reactor-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>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

Add the following lines of configuration to your application.yaml file:

server:
  port: 9090

spring:
  application:
    name: API-GATEWAY
  config:
    import: configserver:http://localhost:9296
  cloud:
    gateway:
      routes:
        - id : ORDER-SERVICE
          uri: lb://ORDER-SERVICE
          predicates:
            - Path=/order/**
          filters:
            - name: CircuitBreaker
              args:
                name: ORDER-SERVICE
                fallbackuri: forward:/orderServiceFallBack
        - id: PRODUCT-SERVICE
          uri: lb://PRODUCT-SERVICE
          predicates:
            - Path=/product/**
          filters:
            - name: CircuitBreaker
              args:
                name: PRODUCT-SERVICE
                fallbackuri: forward:/productServiceFallBack
        - id: PAYMENT-SERVICE
          uri: lb://PAYMENT-SERVICE
          predicates:
            - Path=/payment/**
          filters:
            - name: CircuitBreaker
              args:
                name: PAYMENT-SERVICE
                fallbackuri: forward:/paymentServiceFallBack

FallbackController file

package com.fazaltuts4u.CloudGateway.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class FallbackController {

    @GetMapping("/orderServiceFallBack")
    public String orderServiceFallback(){
        return "Order Service is down!";
    }

    @GetMapping("/productServiceFallBack")
    public String productServiceFallback(){
        return "Product Service is down!";
    }

    @GetMapping("/paymentServiceFallBack")
    public String paymentServiceFallback(){
        return "Payment Service is down!";
    }
}

Main Class

package com.fazaltuts4u.CloudGateway;

import io.github.resilience4j.circuitbreaker.CircuitBreakerConfig;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.circuitbreaker.resilience4j.Resilience4JCircuitBreakerFactory;
import org.springframework.cloud.circuitbreaker.resilience4j.Resilience4JConfigBuilder;
import org.springframework.cloud.client.circuitbreaker.Customizer;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
public class CloudGatewayApplication {

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

    @Bean
    public Customizer<Resilience4JCircuitBreakerFactory> defaultCustomizer(){
        return factory -> factory.configureDefault(
                id -> new Resilience4JConfigBuilder(id)
                        .circuitBreakerConfig(CircuitBreakerConfig.ofDefaults())
                        .build()
        );
    }

}

I hope this helps! Let me know if you have any questions or if there's anything else I can assist you with.

Happy coding! πŸ‘¨β€πŸ’»

Darwen answered 1/6, 2023 at 13:15 Comment(0)
N
0

use these versions:

parent version=2.4.3
spring-cloud version=2020.0.1

import dependencies:

spring-cloud-starter-circuitbreaker-reactor-resilience4j
jersey-apache-client4       

Thanks

Neoptolemus answered 16/12, 2021 at 6:46 Comment(0)
F
0

Add this dependency in your pom.xml file:

<dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
            <version>2.2.10.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-circuitbreaker-reactor-resilience4j -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-circuitbreaker-reactor-resilience4j</artifactId>
            <version>2.1.0</version>
</dependency>
Freidafreight answered 26/1, 2022 at 5:42 Comment(0)
P
0

Adding spring-cloud-starter-circuitbreaker-reactor-resilience4j dependency worked in my case. I have API-gateway with Java 11 and spring-boot version 2.7.1

Here is the dependency versions for spring-boot,netflix-hystrix and reilience4j

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

<dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
        <version>2.2.10.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-circuitbreaker-reactor-resilience4j</artifactId>
        <version>2.1.3</version>
    </dependency>
Pulido answered 10/7, 2022 at 3:8 Comment(0)
R
0

If you're using Spring Cloud Gateway, it's a webflux application and reactive, so you'll need to use the reactive version of resilience4j.

spring-cloud-starter-circuitbreaker-reactor-resilience4j

Ritzy answered 13/6 at 14:36 Comment(0)

© 2022 - 2024 β€” McMap. All rights reserved.