dd-trace-java icon indicating copy to clipboard operation
dd-trace-java copied to clipboard

[GraalVM] Uncaught exception java.lang.NoClassDefFoundError: Could not initialize class jnr.unixsocket.UnixSocketChannel in dd-profiler-http-dispatcher

Open khannedy opened this issue 1 year ago • 7 comments

We use datadog agent in native-image graalvm, but when deploy, we get error class not found


Nov 20, 2024 @ 10:20:02.241 | [dd.trace 2024-11-20 10:20:02:241 +0700] [dd-profiler-http-dispatcher] ERROR java.util.concurrent.ThreadPoolExecutor$Worker - Uncaught exception java.lang.NoClassDefFoundError: Could not initialize class jnr.unixsocket.UnixSocketChannel in dd-profiler-http-dispatcher
-- | --

  | Nov 20, 2024 @ 10:20:02.241 | java.lang.NoClassDefFoundError: Could not initialize class jnr.unixsocket.UnixSocketChannel

  | Nov 20, 2024 @ 10:20:02.241 | at datadog.common.socket.UnixDomainSocketFactory.createSocket(UnixDomainSocketFactory.java:38)

  | Nov 20, 2024 @ 10:20:02.241 | at datadog.okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:241)

  | Nov 20, 2024 @ 10:20:02.241 | at datadog.okhttp3.internal.connection.RealConnection.connect(RealConnection.java:167)

  | Nov 20, 2024 @ 10:20:02.241 | at datadog.okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:258)

  | Nov 20, 2024 @ 10:20:02.241 | at datadog.okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:135)

  | Nov 20, 2024 @ 10:20:02.241 | at datadog.okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:114)

  | Nov 20, 2024 @ 10:20:02.241 | at datadog.okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)

  | Nov 20, 2024 @ 10:20:02.241 | at datadog.okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)

  | Nov 20, 2024 @ 10:20:02.241 | at datadog.okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)

  | Nov 20, 2024 @ 10:20:02.241 | at datadog.okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)

  | Nov 20, 2024 @ 10:20:02.241 | at datadog.okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)

  | Nov 20, 2024 @ 10:20:02.241 | at datadog.okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)

  | Nov 20, 2024 @ 10:20:02.241 | at datadog.okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)

  | Nov 20, 2024 @ 10:20:02.241 | at datadog.okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)

  | Nov 20, 2024 @ 10:20:02.241 | at datadog.okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:127)

  | Nov 20, 2024 @ 10:20:02.241 | at datadog.okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)

  | Nov 20, 2024 @ 10:20:02.241 | at datadog.okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)

  | Nov 20, 2024 @ 10:20:02.241 | at datadog.okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:257)

  | Nov 20, 2024 @ 10:20:02.241 | at datadog.okhttp3.RealCall$AsyncCall.execute(RealCall.java:201)

  | Nov 20, 2024 @ 10:20:02.241 | at datadog.okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)

  | Nov 20, 2024 @ 10:20:02.241 | at [email protected]/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)

  | Nov 20, 2024 @ 10:20:02.241 | at [email protected]/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)

  | Nov 20, 2024 @ 10:20:02.241 | at [email protected]/java.lang.Thread.runWith(Thread.java:1596)

  | Nov 20, 2024 @ 10:20:02.241 | at [email protected]/java.lang.Thread.run(Thread.java:1583)

  | Nov 20, 2024 @ 10:20:02.241 | at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:833)

  | Nov 20, 2024 @ 10:20:02.241 | at org.graalvm.nativeimage.builder/com.oracle.svm.core.posix.thread.PosixPlatformThreads.pthreadStartRoutine(PosixPlatformThreads.java:211)

  | Nov 20, 2024 @ 10:19:49.487 | [dd.trace 2024-11-20 10:19:49:486 +0700] [dd-task-scheduler] INFO datadog.communication.monitor.DDAgentStatsDConnection - Detected /var/run/datadog/dsd.socket.  Using it to send StatsD data.

  | Nov 20, 2024 @ 10:19:48.689 | [dd.trace 2024-11-20 10:19:48:689 +0700] [dd-task-scheduler] WARN com.datadog.profiling.controller.openjdk.events.SmapEntryFactory - Smap entry events could not be registered due to missing systemMap operation


we build the image using this command

RUN native-image  \
    -H:+UnlockExperimentalVMOptions \
    -H:Name=/app/application \
    -J-javaagent:/app/agent/dd-java-agent.jar \
    -J-Ddd.profiling.enabled=true \
    --enable-monitoring=heapdump,jfr \
    --initialize-at-build-time="datadog.trace.api.Functions\$PrefixJoin,datadog.trace.bootstrap.instrumentation.decorator.BaseDecorator,datadog.trace.bootstrap.instrumentation.decorator.AsyncResultDecorator,datadog.trace.instrumentation.reactor.core.ReactorAsyncResultSupportExtension,datadog.trace.instrumentation.reactivestreams.ReactiveStreamsAsyncResultSupportExtension" \
    --verbose \
    --static \
    --libc=musl \
    --allow-incomplete-classpath \
    --report-unsupported-elements-at-runtime \
    -cp "$(cat /app/classpath.txt)" $(cat /app/mainclass.txt)

khannedy avatar Nov 20 '24 03:11 khannedy