Error attaching to process: sun.jvm.hotspot.debugger.DebuggerException: cannot open binary file
Asked Answered
H

5

27

When I use jmap to get the heap info about a process, I got error like that:

$jmap -heap process_id

Attaching to process ID process_id, please wait...
Error attaching to process: sun.jvm.hotspot.debugger.DebuggerException: cannot open binary
file
sun.jvm.hotspot.debugger.DebuggerException: sun.jvm.hotspot.debugger.DebuggerException:
cannot open binary file    

OS: Ubuntu 14.04

I have solved another error (DebuggerException: Can't attach to the process) by updating kernel.yama.ptrace_scope = 0.

See: https://bugs.openjdk.java.net/browse/JDK-7050524

Hillock answered 2/8, 2016 at 1:29 Comment(4)
Did you research the error you're getting?Germanize
Possible duplicate of Jmap can't connect to make a dumpGermanize
You mean it is a permission problem? But I run this command by the same user with the java process.Hillock
After I restart my os, I start java process and use jmap again. There are no error. So it maybe permission probelm. But I am not sure about it.Hillock
S
32

I faced the same issue, however when I su'd to the correct user having the relevant permissions the issue went away.

Skip answered 17/11, 2016 at 9:22 Comment(2)
Interesting enought: Beeing root did not do the trick for me. I used sudo -u THE__USER_RUNNING_THE_JVM ... and then it worked.Dido
Thanks a lot! Saved me tons of time!Brookweed
C
18

Not directly related to the question asked. But, I encountered a similar error while using the jstack command while taking the thread dump of a java process. Let's say the pid of the java process for which I wanted thread dump is 1234.

I had used the command jstack -l 1234 /home/users/a/thread-dump.txt

What I missed in the above command is the redirection operator(>). The correct version of the command is

jstack -l 1234  > /home/users/a/thread-dump.txt

Maybe it helps someone :)

Chickamauga answered 20/11, 2019 at 17:17 Comment(1)
It is also a solution for "java.lang.RuntimeException: Unable to deduce type of thread from address" error.Perrine
P
5

This will also happen if you attempt to attach to an ineligible process so it's a good idea to reconfirm your pid.

For example, a friend of mine got this when they attempted to attach to the jps process they used to search for eligible pids ;).

Phthalein answered 8/9, 2017 at 14:54 Comment(0)
S
4

In our case, the java process was using .../JAVA_HOME/jre/bin/java binary and the jmap process was using .../JAVA_HOME/bin/jmap binary.

Once we changed java process to use .../JAVA_HOME/bin/java binary, then the issue got resolved. We were able to run the jmap successfully.

Key is to use run the java process using JDK java binary instead of JRE java binary.

Swallowtailed answered 27/5, 2020 at 13:19 Comment(1)
Thank you very much, this was the solution for my problem. I spent days to solve it :)Phene
D
0

I had the same issue with jstack. It turned out that I wasn't using Oracle JRE but OpenJDK as runtime for the process, but had only Oracle's JDK installed. Oracle's jstack cannot access an OpenJDK process. See also Does OpenJDK have a tool similar to jstack (Oracle Java)?

Downswing answered 27/11, 2020 at 21:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.