Reputation: 1
Here is the position,when i use java agent to attach a running java project,it failed.It reported "Agent JAR not found or no Agent-Class attribute". I know this is not the reason of my agent because it successed when i quickly restart the java project and attach the agent to the project as soon as possible.But when i attached after the seconds when the java project started,it got "Agent JAR not found or no Agent-Class attribute" error.
agentmain code:
package org.test;
public class test{
public static void agentmain(String agentArgs, Instrumentation inst) throws IOException, UnmodifiableClassException, IllegalClassFormatException, NoSuchFieldException, IllegalAccessException {
Class[] classes = inst.getAllLoadedClasses();
for (Class aClass : classes) {
if (aClass.getName().equals(DDDFFEE.editClassName)){
inst.addTransformer(new DDDFFEE(),true);
inst.retransformClasses(aClass);
}
}
}
}
MANIFEST.MF
Manifest-Version: 1.0
Agent-Class: org.test.test
Can-Redefine-Classes: true
Can-Retransform-Classes: true
The java project is a spring boot web application,and i don't konw why it became like this.
How to attach the running java process whenever the java project start?
I tried lots of times,and check the environments,the java version is the same,the pid file exists,but it worked only when i attach the java process when it started in 1 second,how to solve this?
Upvotes: 0
Views: 370