Impossible to use Feign inside a InfoContributor (circular dependency)
See original GitHub issueI’m trying to implement a info contributor which will query some data from database and one endpoint but it seems sleuth with feign client doesn’t play well inside InfoContributor.
If I remove sleuth the application works fine.
2019-04-15 17:33:03.536 INFO [-,,,] 32324 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-04-15 17:33:03.536 INFO [-,,,] 32324 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 5342 ms
2019-04-15 17:33:04.696 ERROR [-,,,] 32324 --- [ main] o.s.b.web.embedded.tomcat.TomcatStarter : Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'traceWebFilter' defined in class path resource [org/springframework/cloud/sleuth/instrument/web/TraceWebServletAutoConfiguration.class]: Unsatisfied dependency expressed through method 'traceWebFilter' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'tracingFilter' defined in class path resource [org/springframework/cloud/sleuth/instrument/web/TraceWebServletAutoConfiguration.class]: Unsatisfied dependency expressed through method 'tracingFilter' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'httpTracing' defined in class path resource [org/springframework/cloud/sleuth/instrument/web/TraceHttpAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [brave.http.HttpTracing]: Factory method 'httpTracing' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'infoEndpoint' defined in class path resource [org/springframework/boot/actuate/autoconfigure/info/InfoEndpointAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.info.InfoEndpoint]: Factory method 'infoEndpoint' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'pendingReservationInfoContributor' defined in file [D:\work\workspaces\relocation-service\target\classes\com\zooplus\logistics\relocation\actuator\PendingReservationInfoContributor.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.zooplus.logistics.relocation.client.ConfigurationClient': FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'feignBuilder' defined in class path resource [org/springframework/cloud/sleuth/instrument/web/client/feign/TraceFeignClientAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [feign.Feign$Builder]: Factory method 'feignBuilder' threw exception; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'httpTracing': Requested bean is currently in creation: Is there an unresolvable circular reference?
2019-04-15 17:33:04.710 INFO [-,,,] 32324 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2019-04-15 17:33:04.715 WARN [-,,,] 32324 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
2019-04-15 17:33:04.731 INFO [-,,,] 32324 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-04-15 17:33:04.734 ERROR [-,,,] 32324 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
The dependencies of some of the beans in the application context form a cycle:
traceWebFilter defined in class path resource [org/springframework/cloud/sleuth/instrument/web/TraceWebServletAutoConfiguration.class]
↓
tracingFilter defined in class path resource [org/springframework/cloud/sleuth/instrument/web/TraceWebServletAutoConfiguration.class]
┌─────┐
| httpTracing defined in class path resource [org/springframework/cloud/sleuth/instrument/web/TraceHttpAutoConfiguration.class]
↑ ↓
| infoEndpoint defined in class path resource [org/springframework/boot/actuate/autoconfigure/info/InfoEndpointAutoConfiguration.class]
↑ ↓
| pendingReservationInfoContributor defined in file [D:\work\workspaces\relocation-service\target\classes\com\zooplus\logistics\relocation\actuator\PendingReservationInfoContributor.class]
↑ ↓
| com.zooplus.logistics.relocation.client.ConfigurationClient
↑ ↓
| feignBuilder defined in class path resource [org/springframework/cloud/sleuth/instrument/web/client/feign/TraceFeignClientAutoConfiguration.class]
└─────┘
Spring Boot 2.1.3.RELEASE Spring Cloud Greenwich.SR1
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:12 (6 by maintainers)
Top Results From Across the Web
unclear circular dependency with FeignClient and Spring boot
It happens becasue IAutoOpsGnsFlowInitiator is dependent on the feign client which depend on AutoopsClientPostBootListener. But FeignClient ...
Read more >Circular Dependencies in Spring - Baeldung
A quick writeup on dealing with circular dependencies in Spring: how they occur and several ways to work around them.
Read more >Spring Boot 2 Unsatisfied Dependency On Feign Client
Hi it seem to be quite hard to deploy Spring Boot applications to AWS Lambda. ... Impossible to use Feign inside a InfoContributor...
Read more >Fix Spring Boot Circular Dependencies Problem - YouTube
Hi, thanks for watching our video about ! In this video we'll talk about a problem name as Circular Dependency. Circular dependency in...
Read more >SpringBoot 2.6.x coping strategies after disabling cyclic ...
1. Preface SpringBoot 2.6.x does not recommend the use of circular dependencies, which is good news, SpringBoot is gradually guiding ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@marcingrzejszczak I have applied your workaround for our case – it is working now. Thanks!
Oh sorry, you mentioned snapshot not milestone. Anyways, I tried with latest snapshot also and didn’t work.
Thank you for taking a look on it 😃