I try to instrument a java class called ThreadPoolExecutor
and i want to get details of threads using slf4j loggers and I am getting following error
Exception in thread "pool-2-thread-2" Exception in thread "pool-2-thread-1" java.lang.NoClassDefFoundError: com/github/shehanperera/threadagent/MonitorInterceptor
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java)
at java.lang.Thread.run(Thread.java:748)java.lang.NoClassDefFoundError: com/github/shehanperera/threadagent/MonitorInterceptor
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java)
at java.lang.Thread.run(Thread.java:748)
And this is my Agent
new AgentBuilder.Default()
.with(new AgentBuilder.InitializationStrategy.SelfInjection.Eager())
.ignore(ElementMatchers.none())
.type(ElementMatchers.nameContains("ThreadPoolExecutor"))
.transform((builder, type, classLoader, module) -> builder
.method(ElementMatchers.nameContains("run"))
.intercept(Advice.to(MonitorInterceptor.class))
).installOn(instrumentation);
And My MonitorInterceptor
public class MonitorInterceptor {
public static Logger logger = LoggerFactory.getLogger(MonitorInterceptor.class.getName());
@Advice.OnMethodEnter
static void enter(@Advice.Origin String method) throws Exception {
logger.info(String.valueOf(Arrays.asList(Thread.currentThread().getStackTrace())));
}}
logger works normal way and without logger this works. When i try to use logger in enter method like above error will occurs. Any suggestion on This!