如果java进程是通过system-service启动的,不能使用arthas监听吗?
- [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
重现问题的步骤
- 如果进程是做在system-service中的,arthas无法识别到这个java进程。
- /tmp目录下和直接启动java的进程不同,但是我看也有jvm信息。
- 会考虑支持一下这种启动情况吗?虽然这种情况jps -l也无法查看到。
期望的结果
- 做在system-serive中的java进程,也可以被arthas正常识别。
实际运行的结果
- 做在system-service中的java进程,arthas无法识别。
把异常信息贴到这里
https://arthas.aliyun.com/doc/quick-start.html#_2-%E5%90%AF%E5%8A%A8-arthas 执行该程序的用户需要和目标进程具有相同的权限
只要是jvm启动启动都应该可以,使用跟进程相同的用户和传递pid就行
如果使用windows service wrapper启动的jvm, 会报出以下报错,目前没有找到好的解决方法:
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.
下载全量包,解压后有一个as-service.bat,可以试下。