Error attaching to core file: Can't attach to the core file 错误

来源:互联网 发布:淘宝刷钻qq群 编辑:程序博客网 时间:2024/06/10 07:15

Error attaching to core file: Can’t attach to the core file 错误

在使用jmap、jstack、jinfo指令时,可能会碰到“Error attaching to core file: Can’t attach to the core file”错误,实际上这个错误很简单,JVM要求你必须使用对应JDK版本jmap、jstack指令来执行。
例如我本机器的配置:

$ java -versionjava version "1.8.0_112-ea"Java(TM) SE Runtime Environment (build 1.8.0_112-ea-b01)Java HotSpot(TM) 64-Bit Server VM (build 25.112-b01, mixed mode)

而Tomcat环境配置的JDK版本为jdk1.7.0_79,所以当启动Tomcat后,如果直接使用jmap或者jstack指令,必然就会出错,如果要避免这种错误,那么就要到jdk1.7.0_79安装的bin目录下再执行jmap或jinfo指令。

$ jinfo flag 92203Attaching to core 92203 from executable flag, please wait...ERROR: can't open core fileError attaching to core file: Can't attach to the core filesun.jvm.hotspot.debugger.DebuggerException: Can't attach to the core file    at sun.jvm.hotspot.debugger.bsd.BsdDebuggerLocal.attach0(Native Method)    at sun.jvm.hotspot.debugger.bsd.BsdDebuggerLocal.attach(BsdDebuggerLocal.java:295)    at sun.jvm.hotspot.HotSpotAgent.attachDebugger(HotSpotAgent.java:673)    at sun.jvm.hotspot.HotSpotAgent.setupDebuggerDarwin(HotSpotAgent.java:659)    at sun.jvm.hotspot.HotSpotAgent.setupDebugger(HotSpotAgent.java:341)    at sun.jvm.hotspot.HotSpotAgent.go(HotSpotAgent.java:304)    at sun.jvm.hotspot.HotSpotAgent.attach(HotSpotAgent.java:156)    at sun.jvm.hotspot.tools.Tool.start(Tool.java:191)    at sun.jvm.hotspot.tools.Tool.execute(Tool.java:118)    at sun.jvm.hotspot.tools.JInfo.main(JInfo.java:138)    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)    at java.lang.reflect.Method.invoke(Method.java:498)    at sun.tools.jinfo.JInfo.runTool(JInfo.java:108)    at sun.tools.jinfo.JInfo.main(JInfo.java:76)
0 0