Linux calls jmap Error reported permission denied
Solution:
Set permissions for Java installation directory, Java bin directory and jmap command respectively
chmod 777 jdk1.7.0_79
chmod 777 bin
chmod 777 jmap
Linux calls jmap Error reported permission denied
Solution:
Set permissions for Java installation directory, Java bin directory and jmap command respectively
chmod 777 jdk1.7.0_79
chmod 777 bin
chmod 777 jmap
Recently, I changed my laptop. In the new working environment, the jmap command is actually reporting errors, and JPS, jstat, Jinfo and jstack can be used normally. Therefore, the problem of process number is preliminarily eliminated
Attaching to core 17536 from executable heap, please wait...
Error attaching to core file: Windbg Error: OpenDumpFile failed!
sun.jvm.hotspot.debugger.DebuggerException: Windbg Error: OpenDumpFile failed!
at sun.jvm.hotspot.debugger.windbg.WindbgDebuggerLocal.attach0(Native Method)
at sun.jvm.hotspot.debugger.windbg.WindbgDebuggerLocal.attach(WindbgDebuggerLocal.java:160)
at sun.jvm.hotspot.HotSpotAgent.attachDebugger(HotSpotAgent.java:673)
at sun.jvm.hotspot.HotSpotAgent.setupDebuggerWin32(HotSpotAgent.java:569)
at sun.jvm.hotspot.HotSpotAgent.setupDebugger(HotSpotAgent.java:335)
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.PMap.main(PMap.java:72)
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.jmap.JMap.runTool(JMap.java:201)
at sun.tools.jmap.JMap.main(JMap.java:130)
jmap heap XXX
a non-existent process number (a pit is buried here first), but still reported the same error. According to the information of the exception stack, it is suspected that the command line under Windows does not have administrator permissions and cannot access the dump file, so I tried to run CMD as an administrator, and then jmap heap, However, the same mistake is reported: I don’t know how long later, I suddenly remembered — “didn’t you hit the right command?” jmap – H
take a look at the red box in the screenshot, and then lower your head in shame (it must be caused by eating too many mid autumn moon cakes, huh!)
as shown in the figure, jmap has three uses: 1. Connect the running process; 2. Analyze the core file, that is, dump file; 3. Connect the JVM processes of other machines. Therefore, the problem with the jmap heap XXX
command above is that you forget to add “-” and jmap is regarded as analyzing the snapshot file of “heap”, and it is natural to report an error
In JDK’s own toolkit, for commands such as JPS, jmap, jstack, etc., specifying option
generally requires “-” and the following parameters do not contain bars, which should be kept in mind. And make complaints about the exception. Don’t panic. You must read the abnormal information and abnormal stack carefully. In this case, the first line has already been clear. (if you put the filename out, you can print it out better)
Recently, JDK tools jmap and jstack are often used to dump JVM heap and JVM thread stack log to analyze problems. When executing these two commands, I was most puzzled when I encountered this problem: well-known file is not secure
eg:
Google the Internet and find the answer on stackoverflow http://stackoverflow.com/questions/9100149/jstack-well-known-file-is-not-secure?rq=1
It means:
We can find/TMP/hsperfdata on the machine_ $user/$PID is such a file. When we execute jmap or jstack, we first check whether the user executing the command is in contact with hsperfdata_ The users of the $user file are consistent. If not, switch to consistent and then execute.
Get current heap snapshot
jmap – dump:format=b ,file=./ heap.hprof 20344(pid)
20344: well-known file is not secure
sudo -u app-cfg-api jmap – dump:format=b ,file=./ heap.hprof 20344
Dumping heap to /tmp/hsperfdata_ app-cfg-api/ heap.hprof …
Heap dump file created