Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confusing Error: No Feign Client for loadBalancing defined. #517

Closed
brimworks opened this issue Mar 20, 2021 · 4 comments
Closed

Confusing Error: No Feign Client for loadBalancing defined. #517

brimworks opened this issue Mar 20, 2021 · 4 comments
Assignees
Labels
Milestone

Comments

@brimworks
Copy link

Describe the bug
A common scenario is to define a @FeignClient as such:

    @FeignClient(name = "myfeignclient", url = "${my.url}")
    public interface TestFeignClient {
        @GetMapping(value = "/test")
        public Map<String, String> test();
    }

Notice the url is resolved from a property. It also isn't to uncommon to have a configuration which resolves the property to the value of an environment variable:

my:
    url: ${MY_URL}

Now if MY_URL is defined as the empty string, you get this error message:

No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalancer?

Which is very misleading... when the real issue is that no url was defined. I'd suggest changing this line of code:

To be:

if (Objects.isNull(url)) {

It would definitely have helped me out. To work around this issue, I've been adding custom conditional annotations which disable my feign client if the url property is missing or null (since @ConditionalOnProperty will trigger even if it is an empty string).

@OlgaMaciaszek
Copy link
Collaborator

It is by design. If an empty url has been provided, we try resolving the instance with the LB.

@OlgaMaciaszek
Copy link
Collaborator

However, will add an additional log line, saying no URL was resolved.

@OlgaMaciaszek OlgaMaciaszek self-assigned this Apr 12, 2021
@OlgaMaciaszek OlgaMaciaszek added this to To do in Hoxton.SR11 via automation Apr 12, 2021
@OlgaMaciaszek OlgaMaciaszek added this to To do in 2020.0.3 via automation Apr 12, 2021
@OlgaMaciaszek OlgaMaciaszek added this to the 2.2.8.RELEASE milestone Apr 12, 2021
@OlgaMaciaszek OlgaMaciaszek moved this from To do to In progress in Hoxton.SR11 Apr 12, 2021
@OlgaMaciaszek OlgaMaciaszek moved this from To do to In progress in 2020.0.3 Apr 12, 2021
Hoxton.SR11 automation moved this from In progress to Done Apr 12, 2021
2020.0.3 automation moved this from In progress to Done Apr 12, 2021
@brimworks
Copy link
Author

Thanks. Hopefully that extra logging will avoid the problems I had.

@michaldo
Copy link
Contributor

@OlgaMaciaszek, now warning is printed always, even when url is not defined, for example @FeignClient(name = "foo")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
2020.0.3
  
Done
Hoxton.SR11
  
Done
Development

No branches or pull requests

4 participants