Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoSuchMethodError when using agent and modules (JPMS) and selenium #5156

Closed
valodzka opened this issue Jan 17, 2022 Discussed in #5126 · 2 comments · Fixed by #5169
Closed

NoSuchMethodError when using agent and modules (JPMS) and selenium #5156

valodzka opened this issue Jan 17, 2022 Discussed in #5126 · 2 comments · Fixed by #5169
Labels
bug Something isn't working

Comments

@valodzka
Copy link

Discussed in #5126

Originally posted by valodzka January 14, 2022
I'm trying to add agent to my project but see the issue during startup (stack trace below). I think issue is that:

  1. Project uses java module system (JPMS)
  2. Project has selenium-remote as dependency which has opentelementry as dependency

In combination it causes that incorrect version of autoconfigure loaded (shaded vs unshaded).

java.lang.reflect.InvocationTargetException
	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.javaagent.bootstrap.AgentInitializer.initialize(AgentInitializer.java:40)
	at io.opentelemetry.javaagent.OpenTelemetryAgent.agentmain(OpenTelemetryAgent.java:51)
	at io.opentelemetry.javaagent.OpenTelemetryAgent.premain(OpenTelemetryAgent.java:44)
	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 java.instrument/sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:491)
	at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:503)
Caused by: java.lang.NoSuchMethodError: 'io.opentelemetry.sdk.resources.Resource io.opentelemetry.sdk.resources.Resource.create(io.opentelemetry.javaagent.shaded.io.opentelemetry.api.common.Attributes)'
	at io.opentelemetry.javaagent.tooling.AutoVersionResourceProvider.createResource(AutoVersionResourceProvider.java:26)
	at io.opentelemetry.sdk.autoconfigure@1.10.0-alpha/io.opentelemetry.sdk.autoconfigure.ResourceConfiguration.configureResource(ResourceConfiguration.java:42)
	at io.opentelemetry.sdk.autoconfigure@1.10.0-alpha/io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdkBuilder.build(AutoConfiguredOpenTelemetrySdkBuilder.java:186)
	at io.opentelemetry.javaagent.tooling.OpenTelemetryInstaller.installAgentTracer(OpenTelemetryInstaller.java:63)
	at io.opentelemetry.javaagent.tooling.OpenTelemetryInstaller.beforeAgent(OpenTelemetryInstaller.java:35)
	at io.opentelemetry.javaagent.tooling.AgentInstaller.runBeforeAgentListeners(AgentInstaller.java:192)
	at io.opentelemetry.javaagent.tooling.AgentInstaller.installBytebuddyAgent(AgentInstaller.java:122)
	at io.opentelemetry.javaagent.tooling.AgentInstaller.installBytebuddyAgent(AgentInstaller.java:100)
	... 13 more

As stated by @laurit

This is a bug in opentelemetry agent. Agent uses a custom class loader to load most of the agent classes. Unfortunately when running with jpms agent classes that are present in application get loaded from application instead of agent.

@valodzka valodzka changed the title NoSuchMethodError when using agent and modules and selenium NoSuchMethodError when using agent and modules (JPMS) and selenium Jan 17, 2022
@mateuszrzeszutek mateuszrzeszutek added the bug Something isn't working label Jan 17, 2022
@trask
Copy link
Member

trask commented Feb 19, 2022

unfortunately we have to revert the fix for this (#5406), so re-opening

@trask trask reopened this Feb 19, 2022
@trask
Copy link
Member

trask commented Feb 19, 2022

Looks like we don't need to revert (#5408), closing 🥳

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants