alibaba / alibaba/Sentinel

sentinel 1.8.6 导致openfeign接口出现Caused by: java.lang.IllegalStateException: No fallback instance of type

Open
#2,975 1 comment 0 reactions 0 assignees View on GitHub
area/integrations integration/spring-cloud
Dominant language
Java
Stars
23.1k
Forks
8.1k
PR merge metrics
No merged PRs in 30d

Description

## Issue Description

Type: *bug report* or *feature request*

### Describe what happened (or what feature you want)
当设置feign.sentinel.enabled: true时出现如下错误

Caused by: java.lang.IllegalStateException: No fallback instance of type class com.fosafer.voiceprint.platform.module.infra.api.logger.ApiErrorLogApiFallback found for feign client infra-server
at com.alibaba.cloud.sentinel.feign.SentinelFeign$Builder$1.getFromContext(SentinelFeign.java:125)
at com.alibaba.cloud.sentinel.feign.SentinelFeign$Builder$1.create(SentinelFeign.java:104)
at org.springframework.cloud.openfeign.FeignCachingInvocationHandlerFactory.create(FeignCachingInvocationHandlerFactory.java:50)
at feign.ReflectiveFeign.newInstance(ReflectiveFeign.java:64)
at feign.Feign$Builder.target(Feign.java:268)
at org.springframework.cloud.openfeign.DefaultTargeter.target(DefaultTargeter.java:30)
at org.springframework.cloud.openfeign.FeignClientFactoryBean.loadBalance(FeignClientFactoryBean.java:379)
at org.springframework.cloud.openfeign.FeignClientFactoryBean.getTarget(FeignClientFactoryBean.java:427)
at org.springframework.cloud.openfeign.FeignClientFactoryBean.getObject(FeignClientFactoryBean.java:402)
at org.springframework.cloud.openfeign.FeignClientsRegistrar.lambda$registerFeignClient$0(FeignClientsRegistrar.java:235)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1249)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1191)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
... 91 common frames omitted

### Describe what you expected to happen

### How to reproduce it (as minimally and precisely as possible)
代码如下

@FeignClient(name = ApiConstants.NAME,fallback = ApiErrorLogApiFallback.class)
public interface ApiErrorLogApi {

@PostMapping(ApiConstants.PREFIX + "/infra/api-error-log/create")
CommonResult createApiErrorLog(@Valid @RequestBody ApiErrorLogCreateReqDTO createDTO);

}

@Component
public class ApiErrorLogApiFallback implements ApiErrorLogApi {
@Override
public CommonResult createApiErrorLog(ApiErrorLogCreateReqDTO createDTO) {
return CommonResult.timeout();
}
}

1.
2.
3.

### Tell us your environment
2.6.13
2021.0.1
2021.0.1.0
### Anything else we need to know?

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the failure with Spring Boot 2.6.13, Spring Cloud 2021.0.1, Spring Cloud Alibaba 2021.0.1.0, and feign.sentinel.enabled: true. Read the fallback lookup path in com.alibaba.cloud.sentinel.feign.SentinelFeign, especially the getFromContext and create entry points shown in the trace. Done means the provided ApiErrorLogApi fallback is found without the reported exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring-boot
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.