简体   繁体   中英

Datadog instrumentation on Spring boot container application - class not found

I'm currently running a spring boot application as container into a kubernetes cluster. Datadog agent is running as containers on the cluster.

I have modified the container image build to include the datadog agent before running the application:

CMD ["/bin/sh","-c","java -javaagent:dd-java-agent.jar -Ddd.trace.config=datadog.properties -Dlogging.config=/logback.xml -jar service.jar"]

I also setup the environment variable to indicate the HOST IP of the agent to my container via the Deployment file.

The problem now is i'm getting this class not found exception when the application starts:

java.lang.NoClassDefFoundError: datadog/trace/instrumentation/springscheduling/SpringSchedulingInstrumentation
    at java.lang.Class.getDeclaringClass0(Native Method)
    at java.lang.Class.getDeclaringClass(Class.java:1235)
    at java.lang.Class.getEnclosingClass(Class.java:1277)
    at org.springframework.core.annotation.AnnotationsScanner.processClassHierarchy(AnnotationsScanner.java:233)
    at org.springframework.core.annotation.AnnotationsScanner.processClassHierarchy(AnnotationsScanner.java:194)
    at org.springframework.core.annotation.AnnotationsScanner.processClass(AnnotationsScanner.java:128)
    at org.springframework.core.annotation.AnnotationsScanner.process(AnnotationsScanner.java:107)
    at org.springframework.core.annotation.AnnotationsScanner.scan(AnnotationsScanner.java:97)
    at org.springframework.core.annotation.AnnotationsScanner.scan(AnnotationsScanner.java:78)
    at org.springframework.core.annotation.TypeMappedAnnotations.scan(TypeMappedAnnotations.java:242)
    at org.springframework.core.annotation.TypeMappedAnnotations.get(TypeMappedAnnotations.java:149)
    at org.springframework.core.annotation.TypeMappedAnnotations.get(TypeMappedAnnotations.java:131)
    at org.springframework.core.annotation.AnnotationUtils.findAnnotation(AnnotationUtils.java:581)
    at org.springframework.cloud.sleuth.DefaultSpanNamer.annotation(DefaultSpanNamer.java:71)
    at org.springframework.cloud.sleuth.DefaultSpanNamer.name(DefaultSpanNamer.java:58)
    at org.springframework.cloud.sleuth.instrument.async.TraceRunnable.<init>(TraceRunnable.java:59)
    at org.springframework.cloud.sleuth.instrument.async.TraceRunnable.<init>(TraceRunnable.java:51)
    at org.springframework.cloud.sleuth.instrument.async.LazyTraceThreadPoolTaskScheduler.scheduleWithFixedDelay(LazyTraceThreadPoolTaskScheduler.java:265)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.cloud.sleuth.instrument.async.ExecutorMethodInterceptor.invoke(ExecutorBeanPostProcessor.java:328)

Quite straigtforward, i need to include some dependencies into the application package. But i could not find anything useful on datadog website nor maven central repository. Including the agent itself or the api libraries fix nothing. This class is present on the agent but under a different path.

Does anybody know which dependencies should be included in the classpath of the application to fix that ?

Spring is scanning your classpath that seems incomplete. Maybe it is related to Spring's class loading mechanisms. The class in question exists and seems to be part of the agent.

Possibly, you are using an outdated version of the agent.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM