title: Can't get a Java heapdump from a docker container
body: <p>My Java process is stuck and hogging a lot of CPU on the VM. I am trying to get to the root of the issue by getting a heapdump. This process is running in a <code>docker container</code>. I am getting into the container and running a <code>jmap -F -dump:format=b,file=/tmp/heapdump.bin 6</code> as root user. But I still get <code>java.lang.reflect.InvocationTargetException</code>.</p>
  <p>I used <code>jmap -F</code> to get over this exception - <code>com.sun.tools.attach.AttachNotSupportedException: Unable to open socket file: target process not responding or HotSpot VM not loaded</code></p>
  <p>I referenced the this post to make modifications to my query - <a href="https://stackoverflow.com/questions/26140182/running-jmap-getting-unable-to-open-socket-file">Running jmap getting Unable to open socket file</a>,
  I have tried both <code>jmap</code> and <code>jcmd</code> queries, but got the same results.</p>
  <p>Can someone please help here?</p>
  <pre><code># jmap -F -dump:format=b,file=/tmp/heapdump.bin 6
  Attaching to process ID 6, please wait...
  Debugger attached successfully.
  Server compiler detected.
  JVM version is 25.111-b14
  Dumping heap to /tmp/heapdump.bin ...
  Exception in thread &quot;main&quot; java.lang.reflect.InvocationTargetException
      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)
  Caused by: java.lang.InternalError: Metadata does not appear to be polymorphic
      at sun.jvm.hotspot.types.basic.BasicTypeDataBase.findDynamicTypeForAddress(BasicTypeDataBase.java:278)
      at sun.jvm.hotspot.runtime.VirtualBaseConstructor.instantiateWrapperFor(VirtualBaseConstructor.java:102)
      at sun.jvm.hotspot.oops.Metadata.instantiateWrapperFor(Metadata.java:68)
      at sun.jvm.hotspot.memory.DictionaryEntry.klass(DictionaryEntry.java:71)
      at sun.jvm.hotspot.memory.Dictionary.classesDo(Dictionary.java:66)
      at sun.jvm.hotspot.memory.SystemDictionary.classesDo(SystemDictionary.java:190)
      at sun.jvm.hotspot.memory.SystemDictionary.allClassesDo(SystemDictionary.java:183)
      at sun.jvm.hotspot.utilities.HeapHprofBinWriter.writeClasses(HeapHprofBinWriter.java:954)
      at sun.jvm.hotspot.utilities.HeapHprofBinWriter.write(HeapHprofBinWriter.java:427)
      at sun.jvm.hotspot.tools.HeapDumper.run(HeapDumper.java:62)
      at sun.jvm.hotspot.tools.Tool.startInternal(Tool.java:260)
      at sun.jvm.hotspot.tools.Tool.start(Tool.java:223)
      at sun.jvm.hotspot.tools.Tool.execute(Tool.java:118)
      at sun.jvm.hotspot.tools.HeapDumper.main(HeapDumper.java:83)
  </code></pre>