简体   繁体   English

AgentInitializationException:代理 JAR 已加载但代理未能初始化 - 尝试注入 JAR 文件

[英]AgentInitializationException: Agent JAR loaded but agent failed to initialize - trying to inject JAR file

All other questions on the subject did not solve my problem.关于这个主题的所有其他问题都没有解决我的问题。

Injector:注射器:

VirtualMachine vm = VirtualMachine.attach(pid);
vm.loadAgent(new File("inject.jar").getAbsolutePath());
vm.detach();

inject.jar has the correct manifest and everything. inject.jar 有正确的清单和一切。 Inject code:注入代码:

public static void agentmain(String[] args) {
    System.out.println("test");
    // also tried: writing a file to an absolute location,
    // and adding Instrument to the signature above
}

I get the error mentioned in the title when I run the injector.运行注入器时出现标题中提到的错误。

inject.jar manifest:注入.jar清单:

Manifest-Version: 1.0
Agent-Class: Main
Can-Redefine-Classes: true
Can-Retransform-Classes: true

我发现问题出在我的 agentmain 函数中,它使用String[]而不是String作为第一个参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM