window下JConsole无法连接带有"注:将对此进程启用管理代理",解决Exception in thread "VMPanel.connect" java.lang.InternalError

目录

前言

情况

解决


前言

  • 使用JConsole连接java进程的时候报错。

Exception in thread "VMPanel.connect" java.lang.InternalError: Remote thread failed for unknown reason
    at sun.tools.attach.WindowsVirtualMachine.enqueue(Native Method)
    at sun.tools.attach.WindowsVirtualMachine.<init>(WindowsVirtualMachine.java:62)
    at sun.tools.attach.WindowsAttachProvider.attachVirtualMachine(WindowsAttachProvider.java:69)
    at com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:208)
    at sun.tools.jconsole.LocalVirtualMachine.loadManagementAgent(LocalVirtualMachine.java:232)
    at sun.tools.jconsole.LocalVirtualMachine.startManagementAgent(LocalVirtualMachine.java:98)
    at sun.tools.jconsole.ProxyClient.tryConnect(ProxyClient.java:333)
    at sun.tools.jconsole.ProxyClient.connect(ProxyClient.java:313)
    at sun.tools.jconsole.VMPanel$2.run(VMPanel.java:294)

情况

  • 第一次使用JConsole连接java进程是正常的,后面重复连接之后就出现上面的错误了。

解决

  • 在启动的时候加上启动参数
  • -Dcom.sun.management.jmxremote
  • 下面看例子,我这里使用的是idea,修改配置项
    window下JConsole无法连接带有"注:将对此进程启用管理代理",解决Exception in thread "VMPanel.connect" java.lang.InternalError
    window下JConsole无法连接带有"注:将对此进程启用管理代理",解决Exception in thread "VMPanel.connect" java.lang.InternalError
    然后再使用JConsole监控进程就没有问题了。