Fix NoClassDefFoundError for spring-web < 3.1
@@ -26,6 +26,7 @@ package co.elastic.apm.agent.spring.webmvc;
import co.elastic.apm.agent.bci.ElasticApmInstrumentation;
import co.elastic.apm.agent.bci.VisibleForAdvice;
+import co.elastic.apm.agent.bci.bytebuddy.CustomElementMatchers;
import co.elastic.apm.agent.impl.transaction.Transaction;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
@@ -39,6 +40,7 @@ import javax.annotation.Nullable;
import java.util.Collection;
import java.util.Collections;
+import static co.elastic.apm.agent.bci.bytebuddy.CustomElementMatchers.classLoaderCanLoadClass;
import static co.elastic.apm.agent.impl.transaction.AbstractSpan.PRIO_HIGH_LEVEL_FRAMEWORK;
import static net.bytebuddy.matcher.ElementMatchers.hasSuperType;
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
@@ -89,6 +91,12 @@ public class SpringTransactionNameInstrumentation extends ElasticApmInstrumentat
.and(takesArgument(2, Object.class));
}
+ @Override
+ public ElementMatcher.Junction<ClassLoader> getClassLoaderMatcher() {
+ // introduced in spring-web 3.1
+ return classLoaderCanLoadClass("org.springframework.web.method.HandlerMethod");
+ }
+
@Override
public Class<?> getAdviceClass() {
return HandlerAdapterAdvice.class;
