AgentInitializationException: Agent JAR loaded but agent failed to initialize when trying to attach to a running VM
kyngs opened this issue · comments
Describe the bug
I'm trying to attach to a running paper 1.20.5 server.
To Reproduce
Steps to reproduce the behavior:
- Download Paper 1.20.5 https://papermc.io/downloads/paper (I'm using build 6)
- Run it
- Open Recaf
- Attach -> Running Process -> Select the process
- See error
Exception
Here's the stacktrace found in the Paper Process
[13:02:34 ERROR]: [STDERR] [sun.instrument.InstrumentationImpl] WARNING: A Java agent has been loaded dynamically (/usr/share/java/recaf/recaf.jar)
WARNING: If a serviceability tool is in use, please run with -XX:+EnableDynamicAgentLoading to hide this warning
WARNING: If a serviceability tool is not in use, please run with -Djdk.instrument.traceUsage for more information
WARNING: Dynamic loading of agents will be disallowed by default in a future release
[13:02:34 INFO]: 13:02:34.402 [Attach Listener] INFO : Recaf-2.21.13
[13:02:34 INFO]: 13:02:34.403 [Attach Listener] INFO : - Java: 22 (OpenJDK 64-Bit Server VM)
[13:02:34 INFO]: 13:02:34.403 [Attach Listener] INFO : Starting as agent...
[13:02:34 WARN]: java.lang.reflect.InvocationTargetException
[13:02:34 WARN]: at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:118)
[13:02:34 WARN]: at java.base/java.lang.reflect.Method.invoke(Method.java:580)
[13:02:34 WARN]: at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:560)
[13:02:34 WARN]: at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndCallAgentmain(InstrumentationImpl.java:582)
[13:02:34 WARN]: Caused by: java.lang.reflect.InvocationTargetException
> *** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message Outstanding error when calling method in invokeJavaAgentMainMethod at /usr/src/debug/java-openjdk/jdk22u-jdk-22.0.1-0/src/java.instrument/share/native/libinstrument/JPLISAgent.c line: 627
*** java.lang.instrument ASSERTION FAILED ***: "success" with message invokeJavaAgentMainMethod failed at /usr/src/debug/java-openjdk/jdk22u-jdk-22.0.1-0/src/java.instrument/share/native/libinstrument/JPLISAgent.c line: 466
*** java.lang.instrument ASSERTION FAILED ***: "success" with message startJavaAgent failed at /usr/src/debug/java-openjdk/jdk22u-jdk-22.0.1-0/src/java.instrument/share/native/libinstrument/InvocationAdapter.c line: 444
Agent failed to start!
[13:02:34 WARN]: at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:118)
[13:02:34 WARN]: at java.base/java.lang.reflect.Method.invoke(Method.java:580)
[13:02:34 WARN]: at me.coley.recaf.Agent.agent(Agent.java:51)
[13:02:34 WARN]: at me.coley.recaf.Agent.agentmain(Agent.java:41)
[13:02:34 WARN]: at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
[13:02:34 WARN]: ... 3 more
[13:02:34 WARN]: Caused by: java.lang.NoClassDefFoundError: javafx/concurrent/Task
[13:02:34 WARN]: at me.coley.recaf.command.impl.Initializer.run(Initializer.java:60)
[13:02:34 WARN]: at picocli.CommandLine.executeUserObject(CommandLine.java:1939)
[13:02:34 WARN]: at picocli.CommandLine.access$1300(CommandLine.java:145)
[13:02:34 WARN]: at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2358)
[13:02:34 WARN]: at picocli.CommandLine$RunLast.handle(CommandLine.java:2352)
[13:02:34 WARN]: at picocli.CommandLine$RunLast.handle(CommandLine.java:2314)
[13:02:34 WARN]: at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2179)
[13:02:34 WARN]: at picocli.CommandLine$RunLast.execute(CommandLine.java:2316)
[13:02:34 WARN]: at picocli.CommandLine.execute(CommandLine.java:2078)
[13:02:34 WARN]: at me.coley.recaf.Recaf.launch(Recaf.java:103)
[13:02:34 WARN]: at me.coley.recaf.Recaf.agent(Recaf.java:73)
[13:02:34 WARN]: at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
[13:02:34 WARN]: ... 7 more
[13:02:34 WARN]: Caused by: java.lang.ClassNotFoundException: javafx.concurrent.Task
[13:02:34 WARN]: at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445)
[13:02:34 WARN]: at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:592)
[13:02:34 WARN]: at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
[13:02:34 WARN]: ... 19 more
Perhaps this is a duplicate of #650 ? The recaf agent seems to require JavaFX to be on the classpath, which is unreasonable for most processes. Maybe a relic of when Java 8 included it by default?
Recaf 2.x is no longer supported. Please use 4.x. Launcher
cc @Col-E should we pin that 2.x series is not supported anymore?Do I understand correctly that recaf 2.x should no longer be used? Is there any ETA for a ready to use recaf 4.x release?
You can use it. But we will provide no support for it. Cannot say anything on the ETA. Your issue specifically is resolved in 4.x because we no longer inject Recaf as an application into the target process.
Is there any ETA for a ready to use recaf 4.x release?
You can try it out now and provide feedback! No need to wait for the official release.