Java-AttachNotSupportedException:无法打开套接字文件:未加载HotSpot VM [英] Java - AttachNotSupportedException: Unable to open socket file: HotSpot VM not loaded

查看:157
本文介绍了Java-AttachNotSupportedException:无法打开套接字文件:未加载HotSpot VM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当尝试将代理jar文件附加到在Java中运行的另一个进程时,遇到了例外情况:

When attempting to attach an agent jar file onto another process running in java, I have came across the exception:

com.sun.tools.attach.AttachNotSupportedException: 无法打开套接字文件:目标进程未响应或未加载HotSpot VM

我当时正在使用Java Oracle JDK 8_101 运行linux,但是在回答了这个问题之后,我意识到操作系统对于这个问题的产生无关紧要.

I was running linux, with java Oracle JDK 8_101, however after answering this question I've realized the O.S does not matter for the cause of this problem.

答案:

Answer:

如果遇到此问题,发生在我这里的原因是因为我是从另一个JVM启动程序的,而不是为系统指定的默认JVM.

If you encounter this problem, the reason it occured for me is because I was launching a program from a different JVM, other than the default JVM specified for the system.

即)

程序 A (启动器) 上运行> JVM-1 (例如,JDK_8_1或JDK_8_1/jdk/jre).

程序 A (启动器) ,使用 java -jar programB.jar

Program A (The launcher), creates a process with java -jar programB.jar

程序 B (目标) ,正在系统的默认的JVM, JVM-2 (例如,JDK_8_2或JDK_8_2/jre).

程序 A (启动器) 不能参加程序 B (目标) ,因为JVM 程序 A (启动器) 正在运行,但与程序 B (目标) 正在运行,因此抛出了 com.sun.tools.attach.AttachNotSupportedException:

Program A (The launcher) CANNOT attatch to Program B (The target), because the JVM Program A (The launcher) is running on, does not match the JVM of which Program B (The target) is running on, thus throwing the com.sun.tools.attach.AttachNotSupportedException:

推荐答案

此问题的常见原因:

  • 附加套接字/tmp/.java_pid1234 已删除(例如,通过定期清理/tmp的计划作业).
  • 目标JVM使用 -XX:+ DisableAttachMechanism 选项启动.
  • 正在进行垃圾回收或其他长时间的VM操作(例如,堆转储).
  • JVM无法在附加超时内达到安全点.这种情况很少发生,并且该问题通常是间歇性的.
  • Attach socket /tmp/.java_pid1234 has been removed (e.g. by a scheduled job that periodically cleans up /tmp).
  • Target JVM is started with -XX:+DisableAttachMechanism option.
  • Garbage Collection or other long VM operation (e.g. Heap Dump) is in progress.
  • JVM cannot reach safepoint within attach timeout. This happens rarely, and the problem is typically intermittent.

这篇关于Java-AttachNotSupportedException:无法打开套接字文件:未加载HotSpot VM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆