运行arthas-boot后,连接tomcat后报Current VM java version: 11 do not match target VM java version: 1.8, attach may fail
ccc@cccdeMacBook-Pro 01-arthas-packaging-3.5.0-bin % java -jar arthas-boot.jar
[INFO] arthas-boot version: 3.5.0
[INFO] Found existing java process, please choose one and input the serial number of the process, eg : 1. Then hit ENTER.
* [1]: 22224 org.springframework.ide.vscode.boot.app.BootLanguagServerBootApp
[2]: 22496
[3]: 22211
[4]: 37337 org.apache.catalina.startup.Bootstrap
[5]: 31006 myssh.App
4
[INFO] arthas home: /Users/chyzhong/01-worktools/17-Ali-production/01-arthas-packaging-3.5.0-bin
[INFO] Try to attach process 37337
[WARN] Current VM java version: 11 do not match target VM java version: 1.8, attach may fail.
[WARN] Target VM JAVA_HOME is /Library/Java/JavaVirtualMachines/jdk1.8.0_261.jdk/Contents/Home/jre, arthas-boot JAVA_HOME is /Library/Java/JavaVirtualMachines/jdk-11.0.9.jdk/Contents/Home, try to set the same JAVA_HOME.
[ERROR] Start arthas failed, exception stack trace:
com.sun.tools.attach.AgentLoadException: 0
at jdk.attach/sun.tools.attach.HotSpotVirtualMachine.loadAgentLibrary(HotSpotVirtualMachine.java:108)
at jdk.attach/sun.tools.attach.HotSpotVirtualMachine.loadAgentLibrary(HotSpotVirtualMachine.java:119)
at jdk.attach/sun.tools.attach.HotSpotVirtualMachine.loadAgent(HotSpotVirtualMachine.java:147)
at com.taobao.arthas.core.Arthas.attachAgent(Arthas.java:118)
at com.taobao.arthas.core.Arthas.<init>(Arthas.java:26)
at com.taobao.arthas.core.Arthas.main(Arthas.java:137)
[ERROR] attach fail, targetPid: 37337
原因: arthas-boot使用jdk11,tomcat使用jdk8,不同的jvm环境。
解决办法,指定jdk8来运行arthas-boot:
/Library/Java/JavaVirtualMachines/jdk1.8.0_261.jdk/Contents/Home/bin/java -jar arthas-boot.jar