jenkinsci / lib-file-leak-detector

Java agent that detects file handle leak
http://file-leak-detector.kohsuke.org/
MIT License
237 stars 112 forks source link

Agent JAR not found or no Agent-Class attribute #137

Open shahnihir opened 1 year ago

shahnihir commented 1 year ago

Jenkins and plugins versions report

Environment ```text Paste the output here ```

What Operating System are you using (both controller, and any agents involved in the problem)?

Getting below error while running this agent in open jdk 17 in windows machine in Intellij IDEA

"C:\Program Files\Java\jdk-15.0.2\bin\java.exe" -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:63036,suspend=y,server=n -javaagent:C:\Users\nihir.shah.m2\repository\org\kohsuke\file-leak-detector\1.16-SNAPSHOT\file-leak-detector-1.16-SNAPSHOT.jar -javaagent:C:\Users\nihir.shah\AppData\Local\JetBrains\IdeaIC2021.3\captureAgent\debugger-agent.jar -Dfile.encoding=UTF-8 -classpath "D:\Platform\lib-file-leak-detector\target\classes;C:\Users\nihir.shah.m2\repository\args4j\args4j\2.33\args4j-2.33.jar;C:\Users\nihir.shah.m2\repository\org\ow2\asm\asm\9.5\asm-9.5.jar;C:\Users\nihir.shah.m2\repository\org\ow2\asm\asm-analysis\9.5\asm-analysis-9.5.jar;C:\Users\nihir.shah.m2\repository\org\ow2\asm\asm-commons\9.5\asm-commons-9.5.jar;C:\Users\nihir.shah.m2\repository\org\ow2\asm\asm-tree\9.5\asm-tree-9.5.jar;C:\Users\nihir.shah.m2\repository\org\ow2\asm\asm-util\9.5\asm-util-9.5.jar;C:\Program Files\JetBrains\IntelliJ\lib\idea_rt.jar" org.kohsuke.file_leak_detector.Main 16808 Connected to the target VM, address: '127.0.0.1:63036', transport: 'socket' Could not load field socket from SocketImpl: java.lang.NoSuchFieldException: socket Could not load field serverSocket from SocketImpl: java.lang.NoSuchFieldException: serverSocket File leak detector installed Connecting to 16808 Activating file leak detector at D:\Platform\lib-file-leak-detector\target\classes com.sun.tools.attach.AgentLoadException: Agent JAR not found or no Agent-Class attribute at jdk.attach/sun.tools.attach.HotSpotVirtualMachine.loadAgent(HotSpotVirtualMachine.java:159) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:564) at org.kohsuke.file_leak_detector.Main.run(Main.java:74) at org.kohsuke.file_leak_detector.Main.main(Main.java:38) java -jar file-leak-detector.jar PID [OPTSTR] PID : Process ID to activate file leak detector OPTSTR : Packed option string of the form key1[=value1],key2[=value2],...

Options: help - Show the help screen. noexit - Don't exit after showing the help screen. trace - Log every open/close operation to stderr. trace=FILE - Log every open/close operation to the given file. error=FILE - If 'too many open files' error is detected, send the dump here. By default it goes to stderr. threshold=N - Instead of waiting until 'too many open files', dump once we have N descriptors open. http=PORT - Run a mini HTTP server that you can access to get stats on demand. Specify 0 to choose random available port, -1 to disable, which is default. strong - Don't let GC auto-close leaking file descriptors. listener=S - Specify the fully qualified name of ActivityListener class to activate from beginning. dumpatshutdown - Dump open file handles at shutdown. excludes=FILE - Ignore files opened directly/indirectly in specific methods. File lists 'some.pkg.ClassName.methodName' patterns. Disconnected from the target VM, address: '127.0.0.1:63036', transport: 'socket'

Process finished with exit code 1

Reproduction steps

run in intellij by adding VM parameter as -javaagent:"C:\Users\nihir.shah.m2\repository\org\kohsuke\file-leak-detector\1.16-SNAPSHOT\file-leak-detector-1.16-SNAPSHOT.jar" and argument as

Expected Results

na

Actual Results

"C:\Program Files\Java\jdk-15.0.2\bin\java.exe" -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:63036,suspend=y,server=n -javaagent:C:\Users\nihir.shah.m2\repository\org\kohsuke\file-leak-detector\1.16-SNAPSHOT\file-leak-detector-1.16-SNAPSHOT.jar -javaagent:C:\Users\nihir.shah\AppData\Local\JetBrains\IdeaIC2021.3\captureAgent\debugger-agent.jar -Dfile.encoding=UTF-8 -classpath "D:\Platform\lib-file-leak-detector\target\classes;C:\Users\nihir.shah.m2\repository\args4j\args4j\2.33\args4j-2.33.jar;C:\Users\nihir.shah.m2\repository\org\ow2\asm\asm\9.5\asm-9.5.jar;C:\Users\nihir.shah.m2\repository\org\ow2\asm\asm-analysis\9.5\asm-analysis-9.5.jar;C:\Users\nihir.shah.m2\repository\org\ow2\asm\asm-commons\9.5\asm-commons-9.5.jar;C:\Users\nihir.shah.m2\repository\org\ow2\asm\asm-tree\9.5\asm-tree-9.5.jar;C:\Users\nihir.shah.m2\repository\org\ow2\asm\asm-util\9.5\asm-util-9.5.jar;C:\Program Files\JetBrains\IntelliJ\lib\idea_rt.jar" org.kohsuke.file_leak_detector.Main 16808 Connected to the target VM, address: '127.0.0.1:63036', transport: 'socket' Could not load field socket from SocketImpl: java.lang.NoSuchFieldException: socket Could not load field serverSocket from SocketImpl: java.lang.NoSuchFieldException: serverSocket File leak detector installed Connecting to 16808 Activating file leak detector at D:\Platform\lib-file-leak-detector\target\classes com.sun.tools.attach.AgentLoadException: Agent JAR not found or no Agent-Class attribute at jdk.attach/sun.tools.attach.HotSpotVirtualMachine.loadAgent(HotSpotVirtualMachine.java:159) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:564) at org.kohsuke.file_leak_detector.Main.run(Main.java:74) at org.kohsuke.file_leak_detector.Main.main(Main.java:38) java -jar file-leak-detector.jar PID [OPTSTR] PID : Process ID to activate file leak detector OPTSTR : Packed option string of the form key1[=value1],key2[=value2],...

Options: help - Show the help screen. noexit - Don't exit after showing the help screen. trace - Log every open/close operation to stderr. trace=FILE - Log every open/close operation to the given file. error=FILE - If 'too many open files' error is detected, send the dump here. By default it goes to stderr. threshold=N - Instead of waiting until 'too many open files', dump once we have N descriptors open. http=PORT - Run a mini HTTP server that you can access to get stats on demand. Specify 0 to choose random available port, -1 to disable, which is default. strong - Don't let GC auto-close leaking file descriptors. listener=S - Specify the fully qualified name of ActivityListener class to activate from beginning. dumpatshutdown - Dump open file handles at shutdown. excludes=FILE - Ignore files opened directly/indirectly in specific methods. File lists 'some.pkg.ClassName.methodName' patterns. Disconnected from the target VM, address: '127.0.0.1:63036', transport: 'socket'

Process finished with exit code 1

Anything else?

No response

MarkEWaite commented 1 year ago

"C:\Program Files\Java\jdk-15.0.2\bin\java.exe"

That looks like JDK 15 rather than JDK 17. Are you sure that you're running JDK 17?

shahnihir commented 1 year ago

yes its 17, same error in both, Open jdk 15 and 17

bobrunstein commented 10 months ago

Is this project being actively supported? openjdk version "11.0.16" 2022-07-19 OpenJDK Runtime Environment Temurin-11.0.16+8 (build 11.0.16+8) OpenJDK 64-Bit Server VM Temurin-11.0.16+8 (build 11.0.16+8, mixed mode) C:\Users\runstebo\Downloads>java -jar C:\Users\runstebo\Downloads\file-leak-detector-1.13-jar-with-dependencies.jar 32368 Connecting to 32368 Activating file leak detector at C:\Users\runstebo\Downloads\file-leak-detector-1.13-jar-with-dependencies.jar com.sun.tools.attach.AgentInitializationException: Agent JAR loaded but agent failed to initialize at jdk.attach/sun.tools.attach.HotSpotVirtualMachine.loadAgent(HotSpotVirtualMachine.java:165) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.kohsuke.file_leak_detector.Main.run(Main.java:73) at org.kohsuke.file_leak_detector.Main.main(Main.java:37) java -jar file-leak-detector.jar PID [OPTSTR]

MarkEWaite commented 10 months ago

Is this project being actively supported?

The most recent release is from June 2023 and refers to using Java 11 language features where possible. In that sense, I think that it is actively supported, at least as the library is being used in the Jenkins project.

The most recent commit was 3 weeks ago and adds testing on Java 21. In that sense, I think that it is actively supported, at least as the library is being used in the Jenkins project.

If "actively supported" means something different for you, then you'll need to elaborate further on what you're trying to achieve.