app fails to start when sleuth and zipkin are added

Luiz E. picture Luiz E. · Feb 22, 2017 · Viewed 7.6k times · Source

I have a Spring Boot app that I'm updating to 1.5.1. It works great, until I add Sleuth and Zipkin to classpath

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-sleuth</artifactId>
    </dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-sleuth-zipkin</artifactId>
</dependency>

when these lines are present, I get

2017-02-22 22:33:05.331 ERROR [chathub-api,,,] 7581 --- [           main] o.s.boot.SpringApplication               : Application startup failed

java.lang.NoClassDefFoundError: org/springframework/boot/context/embedded/FilterRegistrationBean

This is my dep. management

<dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Camden.SR4</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

I tried change to Dalston

<dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Dalston.BUILD-SNAPSHOT</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <repositories>
        <repository>
            <id>spring-snapshots</id>
            <name>Spring Snapshots</name>
            <url>https://repo.spring.io/libs-snapshot</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>

but the errors get even stranger

***************************
APPLICATION FAILED TO START
***************************

Description:

Parameter 0 of method envInfoContributor in org.springframework.boot.actuate.autoconfigure.InfoContributorAutoConfiguration required a bean of type 'org.springframework.core.env.ConfigurableEnvironment' that could not be found.

and

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'traceWebFilter' defined in class path resource [org/springframework/cloud/sleuth/instrument/web/TraceWebAutoConfiguration.class]: Unsatisfied dependency expressed through method 'traceWebFilter' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'traceFilter' defined in class path resource [org/springframework/cloud/sleuth/instrument/web/TraceWebAutoConfiguration.class]: Unsatisfied dependency expressed through method 'traceFilter' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sleuthTracer' defined in class path resource [org/springframework/cloud/sleuth/autoconfig/TraceAutoConfiguration.class]: Unsatisfied dependency expressed through method 'sleuthTracer' parameter 4; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'zipkinSpanListener' defined in class path resource [org/springframework/cloud/sleuth/zipkin/ZipkinAutoConfiguration.class]: Unsatisfied dependency expressed through method 'zipkinSpanListener' parameter 2; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.core.env.Environment' available: expected at least 1 bean which qualifies as autowire candidate. Dependenc...

am I missing something I haven't noticed yet?

Answer

Andy Wilkinson picture Andy Wilkinson · Feb 23, 2017

I can't explain the error that you got with Dalston.BUILD-SNAPSHOT, but the error with Camden.SR4 is because it's not compatible with Spring Boot 1.5. I'd recommend upgrading to Camden.SR5 which is compatible with Spring Boot 1.5.