Skip to content

Impossible to use Feign inside a InfoContributor (circular dependency) #1334

@rotilho

Description

@rotilho

I'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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions