java.lang.NoClassDefFoundError: net/bytebuddy/agent/builder/AgentBuilder$Default
code: public class ToStringAgent { public static void premain(String arguments, Instrumentation instrumentation) { new AgentBuilder.Default() .type(isAnnotatedWith(ToString.class)) .transform(new AgentBuilder.Transformer() { @Override public DynamicType.Builder> transform(DynamicType.Builder> builder, TypeDescription typeDescription, ClassLoader classLoader, JavaModule module) { return builder.method(named("toString")) .intercept(FixedValue.value("transformed")); }
}).installOn(instrumentation);
} }
error: Exception in thread "main" java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(Unknown Source) at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(Unknown Source) Caused by: java.lang.NoClassDefFoundError: net/bytebuddy/agent/builder/AgentBuilder$Default at com.fcbox.delay.queue.bytecode.ToStringAgent.premain(ToStringAgent.java:17) ... 6 more desc: The error I use this cmd that java -javaagent:.\delay-queue-1.4.1-SNAPSHOT.jar com.fcbox.delay.queue.bytecode.Example occur.
Did you create your agent as a fat jar? It seems like Byte Buddy is missing in it.