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

Fix missing class errors #5795

Merged
merged 2 commits into from
Apr 11, 2022
Merged

Fix missing class errors #5795

merged 2 commits into from
Apr 11, 2022

Conversation

trask
Copy link
Member

@trask trask commented Apr 11, 2022

I pulled #5724 into our distro to check out the startup perf improvements and ran into some smoke test failures on Wildfly 11, e.g. below stack trace.

I'll open a tracking issue to investigate why the wildfly smoke tests in this repo didn't catch this, maybe we need a bit more instrumentation (e.g. otel-api) in the servlet test app.

WARN  muzzleMatcher - Instrumentation skipped, mismatched references were found: opentelemetry-api [class io.opentelemetry.javaagent.instrumentation.opentelemetryapi.OpenTelemetryApiInstrumentationModule] on ModuleClassLoader for Module "deployment.OpenTelemetryApiSupport.war" from Service Module Loader
WARN  muzzleMatcher - -- <no-source> Failed to generate reference check for: ClassRef: io.opentelemetry.javaagent.instrumentation.opentelemetryapi.trace.BridgedTraceFlags extends java.lang.Object implements io.opentelemetry.api.trace.TraceFlags, io.opentelemetry.javaagent.shaded.io.opentelemetry.api.trace.TraceFlags on classloader ModuleClassLoader for Module "deployment.OpenTelemetryApiSupport.war" from Service Module Loader
java.lang.IllegalStateException: Missing class io.opentelemetry.javaagent.shaded.io.opentelemetry.api.trace.TraceFlags
      at io.opentelemetry.javaagent.tooling.muzzle.HelperReferenceWrapper$Factory.create(HelperReferenceWrapper.java:188)
      at io.opentelemetry.javaagent.tooling.muzzle.HelperReferenceWrapper$Factory.access$200(HelperReferenceWrapper.java:152)
      at io.opentelemetry.javaagent.tooling.muzzle.HelperReferenceWrapper$Factory$ReferenceType.lambda$getSuperTypes$0(HelperReferenceWrapper.java:216)
      at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
      at java.util.Iterator.forEachRemaining(Iterator.java:116)
      at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
      at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
      at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
      at java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(StreamSpliterators.java:313)
      at java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:743)
      at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:647)
      at io.opentelemetry.javaagent.tooling.muzzle.ReferenceMatcher.collectMethodsFromTypeHierarchy(ReferenceMatcher.java:193)
      at io.opentelemetry.javaagent.tooling.muzzle.ReferenceMatcher.checkHelperClassMatch(ReferenceMatcher.java:167)
      at io.opentelemetry.javaagent.tooling.muzzle.ReferenceMatcher.checkMatch(ReferenceMatcher.java:110)
      at io.opentelemetry.javaagent.tooling.muzzle.ReferenceMatcher.getMismatchedReferenceSources(ReferenceMatcher.java:84)
      at io.opentelemetry.javaagent.tooling.instrumentation.InstrumentationModuleInstaller$MuzzleMatcher.doesMatch(InstrumentationModuleInstaller.java:182)
      at io.opentelemetry.javaagent.shaded.instrumentation.api.internal.cache.weaklockfree.AbstractWeakConcurrentMap.lambda$computeIfAbsent$0(AbstractWeakConcurrentMap.java:177)
      at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)
      at io.opentelemetry.javaagent.shaded.instrumentation.api.internal.cache.weaklockfree.AbstractWeakConcurrentMap.computeIfAbsent(AbstractWeakConcurrentMap.java:177)
      at io.opentelemetry.javaagent.shaded.instrumentation.api.internal.cache.weaklockfree.WeakConcurrentMap.computeIfAbsent(WeakConcurrentMap.java:48)
      at io.opentelemetry.javaagent.shaded.instrumentation.api.internal.cache.weaklockfree.WeakConcurrentMap$WithInlinedExpunction.computeIfAbsent(WeakConcurrentMap.java:206)
      at io.opentelemetry.javaagent.shaded.instrumentation.api.internal.cache.WeakLockFreeCache.computeIfAbsent(WeakLockFreeCache.java:21)
      at io.opentelemetry.javaagent.tooling.instrumentation.InstrumentationModuleInstaller$MuzzleMatcher.matches(InstrumentationModuleInstaller.java:164)
      at net.bytebuddy.agent.builder.AgentBuilder$RawMatcher$Conjunction.matches(AgentBuilder.java:1668)
      at net.bytebuddy.agent.builder.AgentBuilder$Default$ExecutingTransformer.doTransform(AgentBuilder.java:11870)
      at net.bytebuddy.agent.builder.AgentBuilder$Default$ExecutingTransformer.transform(AgentBuilder.java:11828)
      at net.bytebuddy.agent.builder.AgentBuilder$Default$ExecutingTransformer.access$1700(AgentBuilder.java:11545)
      at net.bytebuddy.agent.builder.AgentBuilder$Default$ExecutingTransformer$LegacyVmDispatcher.run(AgentBuilder.java:12228)
      at net.bytebuddy.agent.builder.AgentBuilder$Default$ExecutingTransformer$LegacyVmDispatcher.run(AgentBuilder.java:12168)
      at java.security.AccessController.doPrivileged(Native Method)
      at net.bytebuddy.agent.builder.AgentBuilder$Default$ExecutingTransformer.doPrivileged(AgentBuilder.java)
      at net.bytebuddy.agent.builder.AgentBuilder$Default$ExecutingTransformer.transform(AgentBuilder.java:11737)
      at sun.instrument.TransformerManager.transform(TransformerManager.java:188)
      at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:428)
      at java.lang.ClassLoader.defineClass1(Native Method)
      at java.lang.ClassLoader.defineClass(ClassLoader.java:757)
      at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:358)
      at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:437)
      at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:274)
      at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:77)
      at org.jboss.modules.Module.loadModuleClass(Module.java:713)
      at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
      at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:412)
      at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:400)
      at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:116)
      at io.opentelemetry.context.LazyStorage.<clinit>(LazyStorage.java:85)
      at io.opentelemetry.context.ContextStorage.get(ContextStorage.java:72)
      at io.opentelemetry.context.Context.current(Context.java:86)
      at io.opentelemetry.api.trace.Span.current(Span.java:35)
      at com.microsoft.applicationinsights.smoketestapp.TestController.testApi(TestController.java:40)
      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.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)
      at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
      at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
      at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:892)
      at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:797)
      at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
      at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1039)
      at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942)
      at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005)
      at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:897)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)

@trask trask requested a review from a team April 11, 2022 05:40

public static AgentLocationStrategy locationStrategy() {
return locationStrategy(null);
return LOCATION_STRATEGY;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to confirm the fix is to not pass null in this codepath?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. The problem is probably that wildfly class loader doesn't unconditionally delegate resource lookups to system loader and isn't able to find resources that are in agent jar. Previously it worked because in AgentLocationStrategy we added ClassFileLocator for all parent class loaders, which included system class loader, where the agent is initially loaded. To make resources from agent jar visible we need to add a ClassFileLocator with bootstrap proxy.


public static AgentLocationStrategy locationStrategy() {
return locationStrategy(null);
return LOCATION_STRATEGY;
}

public static AgentLocationStrategy locationStrategy(ClassLoader bootstrapProxy) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we can remove this method

@laurit laurit merged commit fe84d24 into open-telemetry:main Apr 11, 2022
@trask trask deleted the fix-missing-class-errors branch April 11, 2022 23:45
RashmiRam pushed a commit to RashmiRam/opentelemetry-auto-instr-java that referenced this pull request May 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants