-
Notifications
You must be signed in to change notification settings - Fork 1k
Open
Labels
bugSomething isn't workingSomething isn't workingneeds triageNew issue that requires triageNew issue that requires triage
Description
Describe the bug
I disabled the shadow renaming for local builds by adding disableShadowRelocate=true to ~/.gradle/gradle.properties before building. It introduced by https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/docs/contributing/debugging.md#shadow-renaming
My application got following startup failure:
[otel.javaagent 2025-09-19 16:03:40:665 +0800] [main] INFO io.opentelemetry.javaagent.tooling.VersionLogger - opentelemetry-javaagent - version: 2.21.0-SNAPSHOT
OpenTelemetry Javaagent failed to start
java.lang.NullPointerException: Cannot invoke "io.opentelemetry.api.OpenTelemetry.meterBuilder(String)" because "openTelemetry" is null
at io.opentelemetry.instrumentation.runtimemetrics.java8.internal.JmxRuntimeMetricsUtil.getMeter(JmxRuntimeMetricsUtil.java:28)
at io.opentelemetry.instrumentation.runtimemetrics.java8.Classes.registerObservers(Classes.java:48)
at io.opentelemetry.instrumentation.runtimemetrics.java8.Classes.registerObservers(Classes.java:43)
at io.opentelemetry.instrumentation.runtimemetrics.java8.internal.JmxRuntimeMetricsFactory.buildObservables(JmxRuntimeMetricsFactory.java:27)
at io.opentelemetry.instrumentation.runtimemetrics.java17.RuntimeMetricsBuilder.build(RuntimeMetricsBuilder.java:97)
at io.opentelemetry.instrumentation.runtimemetrics.java17.internal.RuntimeMetricsConfigUtil.configure(RuntimeMetricsConfigUtil.java:50)
at io.opentelemetry.instrumentation.javaagent.runtimemetrics.java17.Java17RuntimeMetricsInstaller.afterAgent(Java17RuntimeMetricsInstaller.java:23)
at io.opentelemetry.javaagent.tooling.AgentInstaller.runAfterAgentListeners(AgentInstaller.java:363)
at io.opentelemetry.javaagent.tooling.AgentInstaller.installBytebuddyAgent(AgentInstaller.java:225)
at io.opentelemetry.javaagent.tooling.AgentInstaller.installBytebuddyAgent(AgentInstaller.java:112)
at io.opentelemetry.javaagent.tooling.AgentStarterImpl.start(AgentStarterImpl.java:104)
at io.opentelemetry.javaagent.bootstrap.AgentInitializer$2.run(AgentInitializer.java:66)
at io.opentelemetry.javaagent.bootstrap.AgentInitializer$2.run(AgentInitializer.java:60)
at io.opentelemetry.javaagent.bootstrap.AgentInitializer.execute(AgentInitializer.java:82)
at io.opentelemetry.javaagent.bootstrap.AgentInitializer.initialize(AgentInitializer.java:59)
at io.opentelemetry.javaagent.OpenTelemetryAgent.startAgent(OpenTelemetryAgent.java:59)
at io.opentelemetry.javaagent.OpenTelemetryAgent.premain(OpenTelemetryAgent.java:46)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:560)
at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:572)
Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class io.opentelemetry.context.LazyStorage
at io.opentelemetry.context.ContextStorage.get(ContextStorage.java:72)
at io.opentelemetry.context.Context.current(Context.java:92)
at io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge.currentContext(Java8BytecodeBridge.java:23)
at ch.qos.logback.classic.Logger.callAppenders(Logger.java:255)
at ch.qos.logback.classic.Logger.buildLoggingEventAndAppend(Logger.java:421)
at ch.qos.logback.classic.Logger.filterAndLog_0_Or3Plus(Logger.java:383)
at ch.qos.logback.classic.Logger.log(Logger.java:765)
at org.apache.commons.logging.LogAdapter$Slf4jLocationAwareLog.error(LogAdapter.java:433)
at org.springframework.boot.SpringApplication.reportFailure(SpringApplication.java:826)
at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:801)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:325)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)
at com.example.demo.CPDemoApplication.main(CPDemoApplication.java:110)
Caused by: java.lang.ExceptionInInitializerError: Exception java.lang.NullPointerException [in thread "main"]
at io.opentelemetry.context.Context.root(Context.java:105)
at io.opentelemetry.javaagent.instrumentation.opentelemetryapi.context.AgentContextStorage.getWrappedRootContext(AgentContextStorage.java:82)
at io.opentelemetry.javaagent.instrumentation.opentelemetryapi.context.AgentContextStorage.<init>(AgentContextStorage.java:51)
at io.opentelemetry.javaagent.instrumentation.opentelemetryapi.context.AgentContextStorage.lambda$wrap$0(AgentContextStorage.java:113)
at io.opentelemetry.context.LazyStorage.<clinit>(LazyStorage.java:86)
at io.opentelemetry.context.ContextStorage.get(ContextStorage.java:72)
at io.opentelemetry.context.Context.current(Context.java:92)
at io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge.currentContext(Java8BytecodeBridge.java:23)
at ch.qos.logback.classic.Logger.callAppenders(Logger.java:255)
at ch.qos.logback.classic.Logger.buildLoggingEventAndAppend(Logger.java:421)
at ch.qos.logback.classic.Logger.filterAndLog_0_Or3Plus(Logger.java:383)
at ch.qos.logback.classic.Logger.log(Logger.java:765)
at org.apache.commons.logging.LogAdapter$Slf4jLocationAwareLog.info(LogAdapter.java:454)
at org.springframework.boot.StartupInfoLogger.logStarting(StartupInfoLogger.java:55)
at org.springframework.boot.SpringApplication.logStartupInfo(SpringApplication.java:637)
at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:373)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:314)
... 3 more
Steps to reproduce
Disable the shadow renaming for local builds by adding disableShadowRelocate=true to ~/.gradle/gradle.properties. Start an application by corresponding java agent.
Expected behavior
Application can start up normally
Actual behavior
Application can't start up normally
Javaagent or library instrumentation version
2.21.0-SNAPSHOT
Environment
JDK:
OS:
Additional context
No response
Tip
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingneeds triageNew issue that requires triageNew issue that requires triage