arthas icon indicating copy to clipboard operation
arthas copied to clipboard

如果java进程是通过system-service启动的,不能使用arthas监听吗?

Open GZK0329 opened this issue 1 year ago • 3 comments

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

环境信息

  • arthas-boot.jar 或者 as.sh 的版本:4.0.0
  • Arthas 版本: 4.0.0
  • 操作系统版本: 3.10.0-1062.9.1.ky3.kb8.pg.x86_64
  • 目标进程的JVM版本: 1.8.0_162
  • 执行arthas-boot的版本: 4.0.0

重现问题的步骤

  1. 如果进程是做在system-service中的,arthas无法识别到这个java进程。
  2. /tmp目录下和直接启动java的进程不同,但是我看也有jvm信息。
  3. 会考虑支持一下这种启动情况吗?虽然这种情况jps -l也无法查看到。

期望的结果

  1. 做在system-serive中的java进程,也可以被arthas正常识别。

实际运行的结果

  1. 做在system-service中的java进程,arthas无法识别。
把异常信息贴到这里

GZK0329 avatar Aug 27 '24 03:08 GZK0329

https://arthas.aliyun.com/doc/quick-start.html#_2-%E5%90%AF%E5%8A%A8-arthas 执行该程序的用户需要和目标进程具有相同的权限

WangJi92 avatar Aug 27 '24 06:08 WangJi92

只要是jvm启动启动都应该可以,使用跟进程相同的用户和传递pid就行

lxyyouxiang123 avatar Oct 16 '24 08:10 lxyyouxiang123

如果使用windows service wrapper启动的jvm, 会报出以下报错,目前没有找到好的解决方法: image

zdqpp avatar Oct 17 '24 06:10 zdqpp

Reason: This typically occurs on Windows when attempting to attach Arthas to a Java process that wasn't started using a JDK, but rather a JRE. Simple solution: Make sure you run your target Java application (PID 93928 in your case) using a JDK installation (instead of a JRE). Ensure your JAVA_HOME points explicitly to a JDK, not a JRE. Quick steps to fix: Set your JAVA_HOME environment variable to a JDK path, e.g.:

set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_xxx set PATH=%JAVA_HOME%\bin;%PATH%

Restart the Java application you're trying to attach to, ensuring it uses the JDK.

Run Arthas again:

java -jar arthas-boot.jar <PID>

Why this matters: Arthas relies on JVM's attach mechanism, which only works if the Java process was started using a JDK’s JVM. After performing these steps, the error should be resolved.

sheikmca avatar Mar 09 '25 04:03 sheikmca

下载全量包,解压后有一个as-service.bat,可以试下。

hengyunabc avatar Mar 11 '25 16:03 hengyunabc