java - 将文件附加到进程时出错
问题描述
我正在尝试将代理文件附加到特定进程我的代码:
try{
VirtualMachine virtualMachine = VirtualMachine.attach(pid);
virtualMachine.loadAgent(agentFile.getAbsolutePath());
System.out.println("Agent loaded!");
virtualMachine.detach();
System.out.println("detached");
} catch (IOException | AttachNotSupportedException | AgentLoadException |
AgentInitializationException e){
e.printStackTrace();
}
}
错误:
com.sun.tools.attach.AttachNotSupportedException: Unable to enqueue operation: the target VM does
not support attach mechanism
at sun.tools.attach.WindowsVirtualMachine.<init>(WindowsVirtualMachine.java:64)
at sun.tools.attach.WindowsAttachProvider.attachVirtualMachine(WindowsAttachProvider.java:69)
at com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:208)
at pl.alpaqdev.client.Util.attach(Util.java:46)
at pl.alpaqdev.client.Main.main(Main.java:25)
我也尝试ByteBuddyAgent.attach(agentFile, pid);
过使用byte-buddy,但我遇到了同样的错误。
解决方案
推荐阅读
- python - Local Prefect 项目不会打印/记录结果
- javascript - 当多个匿名 Promise 评估时做某事
- php - Foreach 自定义循环
- javascript - 尝试将图像上传到 GraphCMS 时出现错误 400
- java - java - 如何使用java中的月日格式yyyy从dob计算年龄?前任。(1999 年 3 月 2 日)
- android - 如何在recyclerview android中的single_row_item的每个视图(imageView,textView)上添加不同的点击事件?
- javascript - 在受保护的路由中刷新时反应身份验证“失败”
- javascript - 为什么 React 不显示名称中带有变音符号的图像?
- javascript - 找到在共同项目上合作时间最长的一对员工
- java - RXJava Retrofit 方法 onNext 未调用