Spring-cloud-sleuth: I get a class error when trying to create a reactive spring cloud sleuth zipkin server

Created on 12 Oct 2017  路  8Comments  路  Source: spring-cloud/spring-cloud-sleuth

im trying to use the zipkin-sleuth-stream bits w/ reactive spring.

when i have a pom with the following dependencies:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>zipkin-service</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>zipkin-service</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.0.M5</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8
        </project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <spring-cloud.version>Finchley.BUILD-SNAPSHOT</spring-cloud.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-stream-rabbit</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-config</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-sleuth-zipkin-stream</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-webflux</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>io.zipkin.java</groupId>
            <artifactId>zipkin-autoconfigure-ui</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

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

    <pluginRepositories>
        <pluginRepository>
            <id>spring-snapshots</id>
            <name>Spring Snapshots</name>
            <url>https://repo.spring.io/snapshot</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </pluginRepository>
        <pluginRepository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>https://repo.spring.io/milestone</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>


</project>

and if i add the following 3 annotations to an otherwise plain public static void main Spring Boot app:

@EnableZipkinStreamServer
@EnableDiscoveryClient
@SpringBootApplication

I get the following errors:

'webRequestLoggingFilter' to: [/*]
2017-10-12 13:28:32.227  INFO [zipkin-service,,,] 2940 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-10-12 13:28:32.518  WARN [zipkin-service,,,] 2940 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'metrics' defined in zipkin.server.ZipkinServerConfiguration: Unexpected exception during bean creation; nested exception is java.lang.TypeNotPresentException: Type org.springframework.boot.actuate.metrics.buffer.CounterBuffers not present
2017-10-12 13:28:32.519  INFO [zipkin-service,,,] 2940 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2017-10-12 13:28:32.534  INFO [zipkin-service,,,] 2940 --- [           main] utoConfigurationReportLoggingInitializer : 

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-10-12 13:28:32.539 ERROR [zipkin-service,,,] 2940 --- [           main] o.s.boot.SpringApplication               : Application startup failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'metrics' defined in zipkin.server.ZipkinServerConfiguration: Unexpected exception during bean creation; nested exception is java.lang.TypeNotPresentException: Type org.springframework.boot.actuate.metrics.buffer.CounterBuffers not present
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:518) ~[spring-beans-5.0.0.RELEASE.jar:5.0.0.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:312) ~[spring-beans-5.0.0.RELEASE.jar:5.0.0.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-5.0.0.RELEASE.jar:5.0.0.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310) ~[spring-beans-5.0.0.RELEASE.jar:5.0.0.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-5.0.0.RELEASE.jar:5.0.0.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:756) ~[spring-beans-5.0.0.RELEASE.jar:5.0.0.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:868) ~[spring-context-5.0.0.RELEASE.jar:5.0.0.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.0.0.RELEASE.jar:5.0.0.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:122) ~[spring-boot-2.0.0.M5.jar:2.0.0.M5]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) [spring-boot-2.0.0.M5.jar:2.0.0.M5]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:386) [spring-boot-2.0.0.M5.jar:2.0.0.M5]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.0.M5.jar:2.0.0.M5]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1245) [spring-boot-2.0.0.M5.jar:2.0.0.M5]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1233) [spring-boot-2.0.0.M5.jar:2.0.0.M5]
    at com.example.zipkinservice.ZipkinServiceApplication.main(ZipkinServiceApplication.java:14) [classes/:na]
Caused by: java.lang.TypeNotPresentException: Type org.springframework.boot.actuate.metrics.buffer.CounterBuffers not present
    at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:117) ~[na:1.8.0_131]
    at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:125) ~[na:1.8.0_131]
    at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49) ~[na:1.8.0_131]
    at sun.reflect.generics.visitor.Reifier.reifyTypeArguments(Reifier.java:68) ~[na:1.8.0_131]
    at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:138) ~[na:1.8.0_131]
    at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49) ~[na:1.8.0_131]
    at sun.reflect.generics.repository.ConstructorRepository.getParameterTypes(ConstructorRepository.java:94) ~[na:1.8.0_131]
    at java.lang.reflect.Executable.getGenericParameterTypes(Executable.java:283) ~[na:1.8.0_131]
    at java.lang.reflect.Method.getGenericParameterTypes(Method.java:283) ~[na:1.8.0_131]
    at org.springframework.core.MethodParameter.getGenericParameterType(MethodParameter.java:419) ~[spring-core-5.0.0.RELEASE.jar:5.0.0.RELEASE]
    at org.springframework.core.MethodParameter.getNestedParameterType(MethodParameter.java:434) ~[spring-core-5.0.0.RELEASE.jar:5.0.0.RELEASE]
    at org.springframework.beans.factory.config.DependencyDescriptor.getDependencyType(DependencyDescriptor.java:373) ~[spring-beans-5.0.0.RELEASE.jar:5.0.0.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1077) ~[spring-beans-5.0.0.RELEASE.jar:5.0.0.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.createOptionalDependency(DefaultListableBeanFactory.java:1547) ~[spring-beans-5.0.0.RELEASE.jar:5.0.0.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1047) ~[spring-beans-5.0.0.RELEASE.jar:5.0.0.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:809) ~[spring-beans-5.0.0.RELEASE.jar:5.0.0.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:715) ~[spring-beans-5.0.0.RELEASE.jar:5.0.0.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:458) ~[spring-beans-5.0.0.RELEASE.jar:5.0.0.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1249) ~[spring-beans-5.0.0.RELEASE.jar:5.0.0.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1098) ~[spring-beans-5.0.0.RELEASE.jar:5.0.0.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) ~[spring-beans-5.0.0.RELEASE.jar:5.0.0.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502) ~[spring-beans-5.0.0.RELEASE.jar:5.0.0.RELEASE]
    ... 14 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.actuate.metrics.buffer.CounterBuffers
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_131]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_131]
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335) ~[na:1.8.0_131]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_131]
    at java.lang.Class.forName0(Native Method) ~[na:1.8.0_131]
    at java.lang.Class.forName(Class.java:348) ~[na:1.8.0_131]
    at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:114) ~[na:1.8.0_131]
    ... 35 common frames omitted

Most helpful comment

I don't understand. You can use the Zipkin server as you have until now. It's just a server, it doesn't need to use Boot 2.0 to use all of Zipkin's features. @adriancole might know more about the Zipkin migration plan to Boot 2.0.

I can do that, initially my plan was to wrap it in a Boot 2 app like in the example above.

Why shouldn't it be? I don't understand this concern. Can you elaborate more?

It sounds still is :) great just wanted to make sure of that after discussing the compatibility of zipkin! I need sleuth for many things.

All 8 comments

@dsyer and i realized that spring-cloud-sleuth-zipkin-stream seems o be the culprit. remove it and things work. (but obviously i dont get a zipkin-server).

Yeah. See #727. Short summary: Zipkin doesn't work with Boot 2.0, so if you need a stream server, use Spring Boot 1.5.

@dsyer I get the same exception above by using a non-stream zipkin server, Finchley.M3 and spring boot 2.0.0.M5

 <properties>
    <spring.boot.version>2.0.0.M5</spring.boot.version>
    <spring.cloud.version>Finchley.M3</spring.cloud.version>
 </properties>

 <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-dependencies</artifactId>
        <version>${spring.boot.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
      <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-dependencies</artifactId>
        <version>${spring.cloud.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-starter-config</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
    </dependency>
    <dependency>
      <groupId>io.zipkin.java</groupId>
      <artifactId>zipkin-server</artifactId>
    </dependency>
    <dependency>
      <groupId>io.zipkin.java</groupId>
      <artifactId>zipkin-autoconfigure-ui</artifactId>
      <scope>runtime</scope>
    </dependency>
  </dependencies>
@EnableZipkinServer
@EnableDiscoveryClient
@SpringBootApplication

Reading the #727 I thought it was a problem related to stream-zipkin only. Have i missed something :) ?

@EnableZipkinServer means that you have Zipkin on the classpath. Zipkin is not compatible with Boot 2.0

Thanks @marcingrzejszczak. Regarding Boot 2, is there an alternative to zipkin or there will be one soon? Is sleuth still the right way to continue to produce correlation data regardless of the zipkin server?

Regarding Boot 2, is there an alternative to zipkin or there will be one soon?

I don't understand. You can use the Zipkin server as you have until now. It's just a server, it doesn't need to use Boot 2.0 to use all of Zipkin's features. @adriancole might know more about the Zipkin migration plan to Boot 2.0.

Is sleuth still the right way to continue to produce correlation data regardless of the zipkin server?

Why shouldn't it be? I don't understand this concern. Can you elaborate more?

I don't understand. You can use the Zipkin server as you have until now. It's just a server, it doesn't need to use Boot 2.0 to use all of Zipkin's features. @adriancole might know more about the Zipkin migration plan to Boot 2.0.

I can do that, initially my plan was to wrap it in a Boot 2 app like in the example above.

Why shouldn't it be? I don't understand this concern. Can you elaborate more?

It sounds still is :) great just wanted to make sure of that after discussing the compatibility of zipkin! I need sleuth for many things.

Please don't create custom zipkin servers. It puts undue burden on our ecosystem when you have classpath problems etc. and you almost never need to.

If you need to please chat with us first https://gitter.im/openzipkin/zipkin

Was this page helpful?
0 / 5 - 0 ratings