opentracing-contrib/java-spring-cloud

Error creating bean with name 'io.opentracing.contrib.spring.cloud.async

sumit-gurav opened this issue · 7 comments

Built on  :: Spring Boot ::   (v2.2.1.RELEASE)
2020-01-07 12:01:29.542  INFO 21127 --- [           main] c.h.hummingbird.HummingbirdApplication   : No active profile set, falling back to default profiles: default
2020-01-07 12:01:39.319  WARN 21127 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'io.opentracing.contrib.spring.cloud.async.CustomAsyncConfigurerAutoConfiguration': Unsatisfied dependency expressed through field 'tracer'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'tracer' defined in class path resource [io/opentracing/contrib/java/spring/jaeger/starter/JaegerAutoConfiguration.class]: Unsatisfied dependency expressed through method 'tracer' parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'reporter' defined in class path resource [io/opentracing/contrib/java/spring/jaeger/starter/JaegerAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [io.jaegertracing.spi.Reporter]: Factory method 'reporter' threw exception; nested exception is java.lang.RuntimeException: TUDPTransport cannot connect: 
2020-01-07 12:01:39.358 ERROR 21127 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'io.opentracing.contrib.spring.cloud.async.CustomAsyncConfigurerAutoConfiguration': Unsatisfied dependency expressed through field 'tracer'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'tracer' defined in class path resource [io/opentracing/contrib/java/spring/jaeger/starter/JaegerAutoConfiguration.class]: Unsatisfied dependency expressed through method 'tracer' parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'reporter' defined in class path resource [io/opentracing/contrib/java/spring/jaeger/starter/JaegerAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [io.jaegertracing.spi.Reporter]: Factory method 'reporter' threw exception; nested exception is java.lang.RuntimeException: TUDPTransport cannot connect: 
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:639)
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:116)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:397)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1429)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:207)
	at org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:240)
	at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:722)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:535)
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)
	at com.hhstechgroup.hummingbird.HummingbirdApplication.main(HummingbirdApplication.java:26)
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'tracer' defined in class path resource [io/opentracing/contrib/java/spring/jaeger/starter/JaegerAutoConfiguration.class]: Unsatisfied dependency expressed through method 'tracer' parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'reporter' defined in class path resource [io/opentracing/contrib/java/spring/jaeger/starter/JaegerAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [io.jaegertracing.spi.Reporter]: Factory method 'reporter' threw exception; nested exception is java.lang.RuntimeException: TUDPTransport cannot connect: 
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:787)
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:528)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1338)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1177)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
	at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1287)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1207)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:636)
	... 19 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'reporter' defined in class path resource [io/opentracing/contrib/java/spring/jaeger/starter/JaegerAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [io.jaegertracing.spi.Reporter]: Factory method 'reporter' threw exception; nested exception is java.lang.RuntimeException: TUDPTransport cannot connect: 
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:645)
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:625)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1338)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1177)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
	at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1287)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1207)
	at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:874)
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:778)
	... 32 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [io.jaegertracing.spi.Reporter]: Factory method 'reporter' threw exception; nested exception is java.lang.RuntimeException: TUDPTransport cannot connect: 
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:640)
	... 46 common frames omitted
Caused by: java.lang.RuntimeException: TUDPTransport cannot connect: 
	at io.jaegertracing.thrift.internal.reporters.protocols.ThriftUdpTransport.newThriftUdpClient(ThriftUdpTransport.java:50)
	at io.jaegertracing.thrift.internal.senders.UdpSender.<init>(UdpSender.java:57)
	at io.opentracing.contrib.java.spring.jaeger.starter.JaegerAutoConfiguration.getUdpReporter(JaegerAutoConfiguration.java:113)
	at io.opentracing.contrib.java.spring.jaeger.starter.JaegerAutoConfiguration.reporter(JaegerAutoConfiguration.java:93)
	at io.opentracing.contrib.java.spring.jaeger.starter.JaegerAutoConfiguration$$EnhancerBySpringCGLIB$$40a53a17.CGLIB$reporter$1(<generated>)
	at io.opentracing.contrib.java.spring.jaeger.starter.JaegerAutoConfiguration$$EnhancerBySpringCGLIB$$40a53a17$$FastClassBySpringCGLIB$$8415617b.invoke(<generated>)
	at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244)
	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:363)
	at io.opentracing.contrib.java.spring.jaeger.starter.JaegerAutoConfiguration$$EnhancerBySpringCGLIB$$40a53a17.reporter(<generated>)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
	... 47 common frames omitted
Caused by: java.net.SocketException: Unresolved address
	at java.base/java.net.DatagramSocket.connect(DatagramSocket.java:495)
	at io.jaegertracing.thrift.internal.reporters.protocols.ThriftUdpTransport.newThriftUdpClient(ThriftUdpTransport.java:48)
	... 60 common frames omitted

Class transformation time: 0.513549711s for 8883 classes or 5.781264336372847E-5s per class

Process finished with exit code 1

@sumit-gurav when does this happen? Could you please provide us with your dependency tree mvn dependency:tree?

While build grade

plugins {
id 'com.palantir.docker-run' version '0.20.1'
}

String container = UUID.randomUUID()
String port = getRandomPort()

dockerRun {
name container
image "registry.hhstechgroup.com/general/rabbitmq:3-management"
ports port + ':5672'
daemonize true
env 'RABBITMQ_ERLANG_COOKIE': 'SWQOKODSQALRPCLNMEQG', 'RABBITMQ_DEFAULT_USER': 'rabbitmq', 'RABBITMQ_DEFAULT_PASS': 'rabbitmq', 'RABBITMQ_DEFAULT_VHOST': '/'
}

description = 'Provider Management core services'

dependencies {
compile project(':commons:autoconfigure')
compile project(':commons:commons')
compile project(':commons:commons-audit')
compile project(':commons:commons-services')
compile project(':commons:jwt-filter')

compile "org.springframework.cloud:spring-cloud-starter-netflix-eureka-client"
compile "io.opentracing.contrib:opentracing-spring-jaeger-cloud-starter:1.0.1"
compile group: 'org.springframework.boot', name: 'spring-boot-autoconfigure', version: '2.2.1.RELEASE'
compile "org.springframework.boot:spring-boot-starter"
compile "org.springframework.boot:spring-boot-starter-amqp"
//compile "org.springframework.boot:spring-boot-starter-web"
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '2.2.1.RELEASE'

// compile "org.springframework.boot:spring-boot-starter-actuator"
compile group: 'org.springframework.boot', name: 'spring-boot-starter-actuator', version: '2.2.1.RELEASE'
compile "org.springframework.boot:spring-boot-starter-logging"
compile "org.springframework.boot:spring-boot-starter-data-rest"
compile "org.springframework.security:spring-security-config"
compile "org.apache.commons:commons-collections4:4.1"
compile "com.fasterxml.jackson.core:jackson-databind:2.9.0"
compile "com.google.guava:guava:${guava_version}"
compile(group: 'io.springfox', name: 'springfox-swagger2', version: '2.7.0') {
exclude(module: 'guava')
}
compile "javax.cache:cache-api:1.1.0"
compile "com.hhstechgroup.zoo:zoo-commons:${project.version}"
compile "org.springframework.boot:spring-boot-starter-websocket"
compile "org.springframework.boot:spring-boot-configuration-processor"
compile "org.springframework.boot:spring-boot-starter-cache"
compile "com.hazelcast:hazelcast-spring:3.12"
compile "com.hazelcast:hazelcast-eureka-one:1.0.2"
compile "org.reflections:reflections:0.9.11"
testCompile project(':commons:commons-test')
}

test {
dependsOn tasks.dockerRun
finalizedBy tasks.dockerRemoveContainer
}

dockerRemoveContainer.dependsOn tasks.dockerStop

test.doFirst {
systemProperty 'spring.rabbitmq.addresses', "localhost:" + port
}

buildDocker {
dockerfile {
contextDir = new File(project.buildDir, "libs")

    env ("EUREKA_HOST",                 "http://eureka:8888/config/eureka/")
    env ("SPRING_DATA_MONGODB_URI",     "mongodb://mongo:27017/?retryWrites=true")
    env ("SPRING_RABBITMQ_ADDRESSES",   "rabbit:5672")
    env ("SPRING_PROFILES_ACTIVE",      "prod")
    env ("TZ",                          "US/Eastern")

    expose (13080)

    add (project.file('providermgmt-server.sh'))
    add (project.getName() + '-' + project.getVersion() + '-boot.jar', '/' + project.getName() + '.jar')
    entrypoint (["/providermgmt-server.sh"])
    healthCheck (10, 5, 5, 360, 'curl -f 127.0.0.1:13080/api/providermgmt/actuator/health -s || exit 1')
}

}

buildscript {
ext {
springBootVersion = "2.2.1.RELEASE"
springCloudVersion = "Hoxton.RC1"
}
repositories {
maven { url "http://artifactory.hhstechgroup.com:8081/artifactory/repo" }
maven { url "https://plugins.gradle.org/m2/" }
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
maven { url "https://repo.spring.io/release" }
maven { url "http://repo.spring.io/plugins-release" }
}
dependencies {
classpath("org.jfrog.buildinfo:build-info-extractor-gradle:4.7.5")
classpath("io.spring.gradle:dependency-management-plugin:1.0.6.RELEASE")
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath("org.owasp:dependency-check-gradle:5.2.2")
}
}

plugins {
id "ch.netzwerg.release" version "1.2.5"
id "se.eugenekainara.docker" version "1.3.1"
id "org.sonarqube" version "2.6.2"
id "com.gorylenko.gradle-git-properties" version "1.4.17"
}

group = "com.hhstechgroup.provider-management"

allprojects {

apply plugin: "com.jfrog.artifactory"
apply plugin: "docker"
apply plugin: "idea"
apply plugin: "io.spring.dependency-management"
apply plugin: "jacoco"
apply plugin: "java"
apply plugin: "maven"
apply plugin: "maven-publish"
apply plugin: "org.owasp.dependencycheck"

repositories {
    //Download sources will not work if mavenLocal() is uncomment

// mavenLocal()
maven { url "http://artifactory.hhstechgroup.com:8081/artifactory/local" }
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
maven { url "https://repo.spring.io/release" }
}

dependencyManagement {
    imports {
        mavenBom "org.springframework.boot:spring-boot-dependencies:${springBootVersion}"
        mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
    }
}

}

subprojects {

sourceCompatibility = 10
targetCompatibility = 10

group parent.group
version parent.version

dependencies {
    compileOnly "org.projectlombok:lombok:${lombok_version}"
    testCompile "de.flapdoodle.embed:de.flapdoodle.embed.mongo:${embeded_mongo_version}"
    testCompile "org.springframework.boot:spring-boot-starter-test"
    testImplementation "org.junit.jupiter:junit-jupiter-api:${junit_version}"
    testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junit_version}"
}

task sourcesJar(type: Jar, dependsOn: classes) {
    classifier = "sources"
    from sourceSets.main.allSource
}

jacoco {
    toolVersion = "0.8.2"
}

sonarqube {
    properties {
        property "sonar.java.source", "10"
    }
}

test {
    useJUnitPlatform()
    testLogging {
        events 'FAILED', 'SKIPPED'
    }
    jvmArgs '--add-opens=java.base/java.lang=ALL-UNNAMED', '--illegal-access=warn'
    systemProperty 'spring.data.mongodb.port', '0'
}

artifacts {
    archives sourcesJar
}

publishing {
    publications {
        maven(MavenPublication) {
            from components.java

            artifact (sourcesJar) {
                classifier = "sources"
            }
        }
    }
}

artifactory {
    contextUrl = "http://artifactory.hhstechgroup.com:8081/artifactory"
    publish {
        repository {
            repoKey = version.matches("(.*)SNAPSHOT") ? "libs-snapshot-local" : "libs-release-local"
            username = "${System.getenv('ARTIFACTORY_USR')}"
            password = "${System.getenv('ARTIFACTORY_PSW')}"
            maven = true
        }
        defaults {
            publications("maven")
        }
    }
}

artifactoryPublish.dependsOn build

docker {
    baseImage 'registry.hhstechgroup.com/general/jre-alpine'
    maintainer 'Dev Ops "DevOps@HHSTechGroup.com'
}

}

// Projects with Spring Boot app
configure([project(':audit'), project(':raccoon'), project(':screening-service'),
project(':provider-management'), project(':applications'),
project(':fabric-client'), project(':initial-data'), project(':reporting'), project(':sisense-gateway')]) {

apply plugin: "org.springframework.boot"

dependencies {
    runtime("io.micrometer:micrometer-registry-prometheus")
    compile("net.logstash.logback:logstash-logback-encoder:${logstash_logback_encoder_version}")
}

jar {
    enabled = true
}
bootJar {
    classifier = 'boot'
}

task buildDocker(type: Docker, dependsOn: build) {
    push = project.hasProperty("push")
    tagVersion = !version.matches("(.*)SNAPSHOT") ? project.getVersion() : System.getenv('BRANCH_NAME') ?: "develop"
    tag = 'registry.hhstechgroup.com/provider-management/' + project.getName()
    stageDir = new File(project.buildDir, "libs")
}

}

release {
dependsOn ':fabric-client:buildDocker', ':initial-data:buildDocker',
':applications:buildDocker',':audit:buildDocker',':raccoon:buildDocker',':screening-service:buildDocker',
':provider-management:buildDocker',':reporting:buildDocker', ':sisense-gateway:buildDocker', project.hasProperty("push") ? artifactoryPublish : build
push = project.hasProperty("push")
tagPrefix = ""
}

task jacocoRootReport(type: org.gradle.testing.jacoco.tasks.JacocoReport) {
dependsOn = subprojects.test
additionalSourceDirs = files(subprojects.sourceSets.main.allSource.srcDirs)
sourceDirectories = files(subprojects.sourceSets.main.allSource.srcDirs)
classDirectories = files(subprojects.sourceSets.main.output)
executionData = files(subprojects.jacocoTestReport.executionData)
reports {
html.enabled = true
xml.enabled = true
csv.enabled = false
}
onlyIf = {
true
}
doFirst {
executionData = files(executionData.findAll {
it.exists()
})
}
}

apply from: "gradle/tasks/logging.gradle"
apply from: "gradle/tasks/utils.gradle"

@sumit-gurav could you please provide a project to reproduce? I am not able to reproduce from the code you added here.

@sumit-gurav I am facing the same error in implementation 'io.opentracing.contrib:opentracing-spring-jaeger-cloud-starter:3.2.2'

Yes I am also facing the same error @sumit-gurav can you tell how you solved this error.