arthas icon indicating copy to clipboard operation
arthas copied to clipboard

jdk 17, arthas attach目标进程失败, Agent JAR not found or no Agent-Class attribute

Open sunriseLe opened this issue 1 year ago • 3 comments

  • [x] 我已经在 issues 里搜索,没有重复的issue。

环境信息

  • arthas-boot.jar 或者 as.sh 的版本:3.6.7
  • Arthas 版本: 3.6.7
  • 操作系统版本: centos
  • 目标进程的JVM版本: jdk 17
  • 执行arthas-boot的版本: 3.6.7

重现问题的步骤

  • 在容器中,通过启动arthas,选择对应的进程进行分析
# java -jar arthas-boot.jar
[INFO] JAVA_HOME: /usr/local/xxxopenjdk/jdk-17
[INFO] arthas-boot version: 3.6.7
[INFO] Found existing java process, please choose one and input the serial number of the process, eg : 1. Then hit ENTER.
* [1]: 1 /opt/xxx-agent/xxx-agent.jar
  [2]: 6 io.trino.server.TrinoServer
2
  • 使用结束后,通过stop退出arthas,lsof -i:3658发现3658端口不再被监听
  • 再次尝试使用arthas分析进程,出现Connection refused报错
[INFO] arthas home: /opt/xxx/arthas/arthas
[INFO] Try to attach process 6
Picked up JAVA_TOOL_OPTIONS:

/opt/xxx/arthas/arthas# java -jar arthas-boot.jar 6
[INFO] JAVA_HOME: /usr/local/xxxopenjdk/jdk-17
[INFO] arthas-boot version: 3.6.7
[INFO] arthas home: /opt/xxx/arthas/arthas
[INFO] Try to attach process 6
Picked up JAVA_TOOL_OPTIONS:
[ERROR] Start arthas failed, exception stack trace:
com.sun.tools.attach.AgentLoadException: Agent JAR not found or no Agent-Class attribute
	at jdk.attach/sun.tools.attach.HotSpotVirtualMachine.loadAgent(HotSpotVirtualMachine.java:160)
	at com.taobao.arthas.core.Arthas.attachAgent(Arthas.java:122)
	at com.taobao.arthas.core.Arthas.<init>(Arthas.java:27)
	at com.taobao.arthas.core.Arthas.main(Arthas.java:161)
[INFO] Attach process 6 success.
[INFO] arthas-client connect 127.0.0.1 3658
Connect to telnet server error: 127.0.0.1 3658
java.net.ConnectException: Connection refused
	at java.base/sun.nio.ch.Net.pollConnect(Native Method)
	at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:672)
	at java.base/sun.nio.ch.NioSocketImpl.timedFinishConnect(NioSocketImpl.java:542)
	at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:597)
	at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327)
	at java.base/java.net.Socket.connect(Socket.java:633)
	at org.apache.commons.net.SocketClient.connect(SocketClient.java:188)
	at org.apache.commons.net.SocketClient.connect(SocketClient.java:209)
	at com.taobao.arthas.client.TelnetConsole.process(TelnetConsole.java:306)
	at com.taobao.arthas.client.TelnetConsole.main(TelnetConsole.java:166)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at com.taobao.arthas.boot.Bootstrap.main(Bootstrap.java:629)
Usage: arthas-client [--help] [-c <value>] [-f <value>] [-w <value>] [-t
       <value>] [-h <value>] [target-ip] [port]

Arthas Telnet Client

EXAMPLES:
  java -jar arthas-client.jar 127.0.0.1 3658
  java -jar arthas-client.jar -c 'dashboard -n 1'
  java -jar arthas-client.jar -f batch.as 127.0.0.1

Options and Arguments:
    --help                        Print usage
 -c,--command <value>             Command to execute, multiple commands
                                  separated by ;
 -f,--batch-file <value>          The batch file to execute
 -w,--width <value>               The terminal width
 -t,--execution-timeout <value>   The timeout (ms) of execute commands or batch
                                  file
 -h,--height <value>              The terminal height
 <target-ip>                      Target ip
 <port>                           The remote server port
  • 一旦出现该错误,再也无法通过arthas绑定进程

sunriseLe avatar Aug 21 '23 16:08 sunriseLe

可以清理下arthas的资源,然后重新下载,看下是否会复现这个问题

RaymondLam1 avatar Aug 29 '23 15:08 RaymondLam1

你好,我是李晓芳,我已收到你的邮件,我会定时查看的。欢迎经常联系

sunriseLe avatar Aug 29 '23 15:08 sunriseLe

你好,相同报错刚才也遇到了,后面发现是因为arthas目录权限问题,tomcat 是非root运行的,我把arthas目录放到root家目录下了,用root执行arthas,tomcat的日志输出报错信息“Error opening zip file or JAR manifest missing: /root/arthas/arthas-agent.jar”,把arthas目录放到非root用户的家目录,使用chown修改arthas的所属就解决该问题了。希望能有所帮助 环境: Arthas 版本: 3.7.0 操作系统版本: centos 7.9 jdk版本:1.8.0

YangYaohang avatar Jan 25 '24 06:01 YangYaohang