open-telemetry / opentelemetry-java

OpenTelemetry Java SDK
https://opentelemetry.io
Apache License 2.0
2.01k stars 833 forks source link

maybeAutoConfigureAndSetGlobal fails with java.lang.NoClassDefFoundError: kotlin/jvm/internal/Intrinsics #5166

Closed pedrolamarao closed 1 year ago

pedrolamarao commented 1 year ago

Describe the bug

We have successfully applied OpenTelemetry autoconfiguration in one of our projects.

In this particular project, applying OpenTelemetry autoconfiguration fails with an exception.

This project compiles with -release 11 and defines modules with module-info.java files.

Steps to reproduce

Apply opentelemetry-sdk-extension-autoconfigure to this project.

What did you expect to see?

I expected OpenTelemetry to successfully auto-configure.

What did you see instead?

OpenTelemetry failed to auto-configure with the following stack trace:

GRAVE: Error automatically configuring OpenTelemetry SDK. OpenTelemetry will not be enabled.
java.lang.NoClassDefFoundError: kotlin/jvm/internal/Intrinsics
        at okhttp3@4.10.0/okhttp3.ConnectionPool.<init>(ConnectionPool.kt)
        at okhttp3@4.10.0/okhttp3.ConnectionPool.<init>(ConnectionPool.kt:47)
        at okhttp3@4.10.0/okhttp3.OkHttpClient$Builder.<init>(OkHttpClient.kt:471)
        at io.opentelemetry.exporter.internal@1.22.0/io.opentelemetry.exporter.internal.grpc.GrpcExporterBuilder.build(GrpcExporterBuilder.java:137)
        at io.opentelemetry.exporter.otlp@1.22.0/io.opentelemetry.exporter.otlp.metrics.OtlpGrpcMetricExporterBuilder.build(OtlpGrpcMetricExporterBuilder.java:198)
        at io.opentelemetry.exporter.otlp@1.22.0/io.opentelemetry.exporter.otlp.internal.OtlpMetricExporterProvider.createExporter(OtlpMetricExporterProvider.java:72)
        at io.opentelemetry.sdk.autoconfigure@1.22.0-alpha/io.opentelemetry.sdk.autoconfigure.SpiUtil.lambda$loadConfigurable$0(SpiUtil.java:48)
        at io.opentelemetry.sdk.autoconfigure@1.22.0-alpha/io.opentelemetry.sdk.autoconfigure.NamedSpiManager.tryLoadImplementationForName(NamedSpiManager.java:46)
        at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1708)
        at io.opentelemetry.sdk.autoconfigure@1.22.0-alpha/io.opentelemetry.sdk.autoconfigure.NamedSpiManager.getByName(NamedSpiManager.java:36)
        at io.opentelemetry.sdk.autoconfigure@1.22.0-alpha/io.opentelemetry.sdk.autoconfigure.MetricExporterConfiguration.configureExporter(MetricExporterConfiguration.java:77)
        at io.opentelemetry.sdk.autoconfigure@1.22.0-alpha/io.opentelemetry.sdk.autoconfigure.MetricExporterConfiguration.configureReader(MetricExporterConfiguration.java:55)
        at io.opentelemetry.sdk.autoconfigure@1.22.0-alpha/io.opentelemetry.sdk.autoconfigure.MeterProviderConfiguration.lambda$configureMetricReaders$0(MeterProviderConfiguration.java:89)
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
        at java.base/java.util.Collections$2.tryAdvance(Collections.java:4853)
        at java.base/java.util.Collections$2.forEachRemaining(Collections.java:4861)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
        at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
        at io.opentelemetry.sdk.autoconfigure@1.22.0-alpha/io.opentelemetry.sdk.autoconfigure.MeterProviderConfiguration.configureMetricReaders(MeterProviderConfiguration.java:92)
        at io.opentelemetry.sdk.autoconfigure@1.22.0-alpha/io.opentelemetry.sdk.autoconfigure.MeterProviderConfiguration.configureMeterProvider(MeterProviderConfiguration.java:65)
        at io.opentelemetry.sdk.autoconfigure@1.22.0-alpha/io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdkBuilder.build(AutoConfiguredOpenTelemetrySdkBuilder.java:340)
        at io.opentelemetry.sdk.autoconfigure@1.22.0-alpha/io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk.initialize(AutoConfiguredOpenTelemetrySdk.java:31)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at io.opentelemetry.api@1.22.0/io.opentelemetry.api.GlobalOpenTelemetry.maybeAutoConfigureAndSetGlobal(GlobalOpenTelemetry.java:241)
        at io.opentelemetry.api@1.22.0/io.opentelemetry.api.GlobalOpenTelemetry.get(GlobalOpenTelemetry.java:76)
        at prodist.rsfn.core/prodist.rsfn.core.CoreService$SecurityImpl.create(CoreService.java:113)
        at prodist.rsfn.tool/prodist.rsfn.tool.Tool.withService(Tool.java:561)
        at prodist.rsfn.tool/prodist.rsfn.tool.Tool.pack(Tool.java:147)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at info.picocli/picocli.CommandLine.executeUserObject(CommandLine.java:1972)
        at info.picocli/picocli.CommandLine.access$1300(CommandLine.java:145)
        at info.picocli/picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2358)
        at info.picocli/picocli.CommandLine$RunLast.handle(CommandLine.java:2352)
        at info.picocli/picocli.CommandLine$RunLast.handle(CommandLine.java:2314)
        at info.picocli/picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2179)
        at info.picocli/picocli.CommandLine$RunLast.execute(CommandLine.java:2316)
        at info.picocli/picocli.CommandLine.execute(CommandLine.java:2078)
        at prodist.rsfn.tool/prodist.rsfn.tool.ToolBase.run(ToolBase.java:135)
        at prodist.rsfn.tool/prodist.rsfn.tool.ToolBase.main(ToolBase.java:31)
Caused by: java.lang.ClassNotFoundException: kotlin.jvm.internal.Intrinsics
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
        ... 48 more

What version and what artifacts are you using?

Gradle dependency report:

runtimeClasspath - Runtime classpath of source set 'main'.
+--- project :rsfn-platform
|    +--- project :rsfn-api (c)
|    +--- project :rsfn-core (c)
|    +--- project :rsfn-test (c)
|    \--- project :rsfn-bridge (c)
+--- org.apache.logging.log4j:log4j-bom:2.17.2
|    +--- org.apache.logging.log4j:log4j-api:2.17.2 (c)
|    +--- org.apache.logging.log4j:log4j-slf4j-impl:2.17.2 (c)
|    \--- org.apache.logging.log4j:log4j-core:2.17.2 (c)
+--- org.junit:junit-bom:[5.8,5.9) -> 5.8.2
|    +--- org.junit.platform:junit-platform-launcher:1.8.2 (c)
|    +--- org.junit.jupiter:junit-jupiter:5.8.2 (c)
|    +--- org.junit.platform:junit-platform-engine:1.8.2 (c)
|    +--- org.junit.jupiter:junit-jupiter-api:5.8.2 (c)
|    +--- org.junit.jupiter:junit-jupiter-params:5.8.2 (c)
|    +--- org.junit.jupiter:junit-jupiter-engine:5.8.2 (c)
|    \--- org.junit.platform:junit-platform-commons:1.8.2 (c)
+--- org.slf4j:slf4j-parent:1.7.34
|    \--- org.slf4j:slf4j-api:1.7.34 (c)
+--- project :rsfn-api
|    +--- project :rsfn-platform (*)
|    \--- prodist-jvm:java-11:1.2.0-46+8a8fffde
+--- project :rsfn-bridge
|    \--- com.tdunning:t-digest:3.3
+--- project :rsfn-test
|    +--- project :rsfn-platform (*)
|    +--- project :rsfn-api (*)
|    +--- org.junit:junit-bom:[5.8,5.9) -> 5.8.2 (*)
|    +--- org.mockito:mockito-bom:[4.6,4.7) -> 4.6.1
|    |    +--- org.mockito:mockito-core:4.6.1 (c)
|    |    \--- org.mockito:mockito-junit-jupiter:4.6.1 (c)
|    +--- org.bouncycastle:bcpkix-jdk15on:1.70
|    |    +--- org.bouncycastle:bcprov-jdk15on:1.70
|    |    \--- org.bouncycastle:bcutil-jdk15on:1.70
|    |         \--- org.bouncycastle:bcprov-jdk15on:1.70
|    +--- org.hamcrest:hamcrest:2.2
|    +--- org.junit.jupiter:junit-jupiter -> 5.8.2
|    |    +--- org.junit:junit-bom:5.8.2 (*)
|    |    +--- org.junit.jupiter:junit-jupiter-api:5.8.2
|    |    |    +--- org.junit:junit-bom:5.8.2 (*)
|    |    |    +--- org.opentest4j:opentest4j:1.2.0
|    |    |    \--- org.junit.platform:junit-platform-commons:1.8.2
|    |    |         \--- org.junit:junit-bom:5.8.2 (*)
|    |    +--- org.junit.jupiter:junit-jupiter-params:5.8.2
|    |    |    +--- org.junit:junit-bom:5.8.2 (*)
|    |    |    \--- org.junit.jupiter:junit-jupiter-api:5.8.2 (*)
|    |    \--- org.junit.jupiter:junit-jupiter-engine:5.8.2
|    |         +--- org.junit:junit-bom:5.8.2 (*)
|    |         +--- org.junit.platform:junit-platform-engine:1.8.2
|    |         |    +--- org.junit:junit-bom:5.8.2 (*)
|    |         |    +--- org.opentest4j:opentest4j:1.2.0
|    |         |    \--- org.junit.platform:junit-platform-commons:1.8.2 (*)
|    |         \--- org.junit.jupiter:junit-jupiter-api:5.8.2 (*)
|    +--- org.mockito:mockito-core -> 4.6.1
|    |    +--- net.bytebuddy:byte-buddy:1.12.10
|    |    +--- net.bytebuddy:byte-buddy-agent:1.12.10
|    |    \--- org.objenesis:objenesis:3.2
|    +--- org.mockito:mockito-junit-jupiter -> 4.6.1
|    |    +--- org.mockito:mockito-core:4.6.1 (*)
|    |    \--- org.junit.jupiter:junit-jupiter-api:5.8.2 (*)
|    +--- prodist-jvm:java-11:1.2.0-46+8a8fffde
|    \--- prodist-jvm:sts-jca:[1.5,2.0) -> 1.5.0-225+666248ec
|         +--- prodist-jvm:sts-api:1.5.0-225+666248ec
|         +--- org.bouncycastle:bcprov-jdk15on:1.70
|         \--- org.apache.logging.log4j:log4j-api:2.17.2
+--- info.picocli:picocli:4.6.3
+--- org.junit.platform:junit-platform-launcher -> 1.8.2
|    +--- org.junit:junit-bom:5.8.2 (*)
|    \--- org.junit.platform:junit-platform-engine:1.8.2 (*)
+--- org.apache.logging.log4j:log4j-api -> 2.17.2
+--- org.slf4j:slf4j-api -> 1.7.34
+--- prodist-jvm:java-11:1.2.0-46+8a8fffde
+--- prodist-jvm:sts-jca:[1.5,2.0) -> 1.5.0-225+666248ec (*)
+--- io.opentelemetry:opentelemetry-bom:1.22.0
|    +--- io.opentelemetry:opentelemetry-sdk:1.22.0 (c)
|    +--- io.opentelemetry:opentelemetry-exporter-otlp:1.22.0 (c)
|    +--- io.opentelemetry:opentelemetry-sdk-metrics:1.22.0 (c)
|    +--- io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi:1.22.0 (c)
|    +--- io.opentelemetry:opentelemetry-api:1.22.0 (c)
|    +--- io.opentelemetry:opentelemetry-sdk-common:1.22.0 (c)
|    +--- io.opentelemetry:opentelemetry-sdk-trace:1.22.0 (c)
|    +--- io.opentelemetry:opentelemetry-exporter-otlp-common:1.22.0 (c)
|    +--- io.opentelemetry:opentelemetry-context:1.22.0 (c)
|    \--- io.opentelemetry:opentelemetry-exporter-common:1.22.0 (c)
+--- io.opentelemetry:opentelemetry-exporter-otlp -> 1.22.0
|    +--- io.opentelemetry:opentelemetry-exporter-otlp-common:1.22.0
|    |    +--- io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi:1.22.0
|    |    |    +--- io.opentelemetry:opentelemetry-sdk-metrics:1.22.0
|    |    |    |    +--- io.opentelemetry:opentelemetry-api:1.22.0
|    |    |    |    |    \--- io.opentelemetry:opentelemetry-context:1.22.0
|    |    |    |    \--- io.opentelemetry:opentelemetry-sdk-common:1.22.0
|    |    |    |         +--- io.opentelemetry:opentelemetry-semconv:1.22.0-alpha
|    |    |    |         |    \--- io.opentelemetry:opentelemetry-api:1.22.0 (*)
|    |    |    |         \--- io.opentelemetry:opentelemetry-api:1.22.0 (*)
|    |    |    +--- io.opentelemetry:opentelemetry-sdk-logs:1.22.0-alpha
|    |    |    |    +--- io.opentelemetry:opentelemetry-api-logs:1.22.0-alpha
|    |    |    |    |    \--- io.opentelemetry:opentelemetry-api:1.22.0 (*)
|    |    |    |    \--- io.opentelemetry:opentelemetry-sdk-common:1.22.0 (*)
|    |    |    \--- io.opentelemetry:opentelemetry-sdk:1.22.0
|    |    |         +--- io.opentelemetry:opentelemetry-sdk-logs:1.22.0-alpha (*)
|    |    |         +--- io.opentelemetry:opentelemetry-api:1.22.0 (*)
|    |    |         +--- io.opentelemetry:opentelemetry-sdk-common:1.22.0 (*)
|    |    |         +--- io.opentelemetry:opentelemetry-sdk-trace:1.22.0
|    |    |         |    +--- io.opentelemetry:opentelemetry-semconv:1.22.0-alpha (*)
|    |    |         |    +--- io.opentelemetry:opentelemetry-api:1.22.0 (*)
|    |    |         |    \--- io.opentelemetry:opentelemetry-sdk-common:1.22.0 (*)
|    |    |         \--- io.opentelemetry:opentelemetry-sdk-metrics:1.22.0 (*)
|    |    +--- com.squareup.okhttp3:okhttp:4.10.0
|    |    |    +--- com.squareup.okio:okio:3.0.0
|    |    |    |    \--- com.squareup.okio:okio-jvm:3.0.0
|    |    |    |         +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.31
|    |    |    |         |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.5.31 -> 1.6.20
|    |    |    |         |    |    +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.6.20
|    |    |    |         |    |    \--- org.jetbrains:annotations:13.0
|    |    |    |         |    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.5.31
|    |    |    |         |         \--- org.jetbrains.kotlin:kotlin-stdlib:1.5.31 -> 1.6.20 (*)
|    |    |    |         \--- org.jetbrains.kotlin:kotlin-stdlib-common:1.5.31 -> 1.6.20
|    |    |    \--- org.jetbrains.kotlin:kotlin-stdlib:1.6.20 (*)
|    |    \--- io.opentelemetry:opentelemetry-exporter-common:1.22.0
|    |         \--- io.opentelemetry:opentelemetry-api:1.22.0 (*)
|    +--- io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi:1.22.0 (*)
|    +--- io.opentelemetry:opentelemetry-sdk-trace:1.22.0 (*)
|    \--- io.opentelemetry:opentelemetry-sdk-metrics:1.22.0 (*)
+--- io.opentelemetry:opentelemetry-sdk -> 1.22.0 (*)
+--- io.opentelemetry:opentelemetry-sdk-extension-autoconfigure:1.22.0-alpha
|    +--- io.opentelemetry:opentelemetry-semconv:1.22.0-alpha (*)
|    +--- io.opentelemetry:opentelemetry-sdk:1.22.0 (*)
|    +--- io.opentelemetry:opentelemetry-sdk-metrics:1.22.0 (*)
|    +--- io.opentelemetry:opentelemetry-sdk-logs:1.22.0-alpha (*)
|    \--- io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi:1.22.0 (*)
+--- project :rsfn-core
|    +--- project :rsfn-platform (*)
|    +--- project :rsfn-api (*)
|    +--- org.bouncycastle:bcpkix-jdk15on:1.70 (*)
|    +--- io.opentelemetry:opentelemetry-bom:1.22.0 (*)
|    +--- io.opentelemetry:opentelemetry-api -> 1.22.0 (*)
|    +--- prodist-jvm:sts-jca:[1.5,2.0) -> 1.5.0-225+666248ec (*)
|    +--- org.slf4j:slf4j-parent:1.7.34 (*)
|    +--- org.slf4j:slf4j-api -> 1.7.34
|    \--- prodist-jvm:java-11:1.2.0-46+8a8fffde
\--- org.apache.logging.log4j:log4j-slf4j-impl -> 2.17.2
     +--- org.slf4j:slf4j-api:1.7.25 -> 1.7.34
     +--- org.apache.logging.log4j:log4j-api:2.17.2
     \--- org.apache.logging.log4j:log4j-core:2.17.2
          \--- org.apache.logging.log4j:log4j-api:2.17.2

Environment

java -version openjdk version "17.0.5" 2022-10-18 OpenJDK Runtime Environment Temurin-17.0.5+8 (build 17.0.5+8) OpenJDK 64-Bit Server VM Temurin-17.0.5+8 (build 17.0.5+8, mixed mode, sharing)

OS: Windows 10 22H2

pedrolamarao commented 1 year ago

Applying runtimeOnly("com.squareup.okio:okio:3.3.0") to upgrade this dependency did not change the result.

pedrolamarao commented 1 year ago

Applying runtimeOnly("com.squareup.okhttp3:okhttp:5.0.0-alpha.11") to upgrade this dependency did not change the result.

pedrolamarao commented 1 year ago

Removing module-info.java from this project works.

pedrolamarao commented 1 year ago

This project reproduces the problem: https://github.com/pedrolamarao/opentelemetry-java-issue-5166

jack-berg commented 1 year ago

Closing as duplicate of #4777. Thanks for the reproduction. We're open to ideas / contributions to address this issue.