com.sun.jdi.VMDisconnectedException:从虚拟机获得IOException

时间:2014-07-03 18:57:57

标签: eclipse virtual-machine remote-debugging jdi

我无法摆脱这种异常。我编写了一个程序,使用“com.sun.jdi.SocketAttach”作为附加连接器将调试器附加到远程服务器,一旦建立连接,我添加了一个调试目标。

vm = connector.attach(map)
debugTarget = JDIDebugModel.newDebugTarget(launch, remoteVM, name, null, false, true, true)
launch.addDebugTarget()

我的代码工作正常但每次关闭我的eclipse工作区时都会收到此异常,该工作区具有与服务器的活动调试连接。看起来像这样:

!ENTRY org.eclipse.jdt.debug 4 125 2014-05-28 11:20:22.562
!MESSAGE Internal error logged from JDI Debug:
!STACK 0
com.sun.jdi.VMDisconnectedException: Got IOException from Virtual Machine
at org.eclipse.jdi.internal.connect.PacketSendManager.sendPacket(PacketSendManager.java:89)
at org.eclipse.jdi.internal.MirrorImpl.requestVM(MirrorImpl.java:186)
at org.eclipse.jdi.internal.MirrorImpl.requestVM(MirrorImpl.java:226)
at org.eclipse.jdi.internal.request.EventRequestImpl.disable(EventRequestImpl.java:217)
at org.eclipse.jdi.internal.request.EventRequestManagerImpl.deleteEventRequest(EventRequestManagerImpl.java:367)
at org.eclipse.jdt.internal.debug.core.breakpoints.JavaBreakpoint.removeRequests(JavaBreakpoint.java:769)
at org.eclipse.jdt.internal.debug.core.breakpoints.JavaBreakpoint.removeFromTarget(JavaBreakpoint.java:716)
at org.eclipse.jdt.internal.debug.core.breakpoints.JavaLineBreakpoint.removeFromTarget(JavaLineBreakpoint.java:187)
at org.eclipse.jdt.internal.debug.core.model.JDIDebugTarget.removeAllBreakpoints(JDIDebugTarget.java:1566)
at org.eclipse.jdt.internal.debug.core.model.JDIDebugTarget.cleanup(JDIDebugTarget.java:1522)
at org.eclipse.jdt.internal.debug.core.model.JDIDebugTarget.shutdown(JDIDebugTarget.java:1658)
at org.eclipse.jdt.internal.debug.core.JDIDebugPlugin.stop(JDIDebugPlugin.java:345)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl$2.run(BundleContextImpl.java:771)
at java.security.AccessController.doPrivileged(AccessController.java:330)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.stop(BundleContextImpl.java:764)
at org.eclipse.osgi.framework.internal.core.BundleHost.stopWorker(BundleHost.java:510)

在调查此问题后,我发现即使在VM断开连接后客户端向VM发送请求时也会引发此异常。但在我的情况下,我没有在服务器上部署任何应用程序,我没有调试任何应用程序,仍然关闭工作区后,我得到了这个例外。

我尝试实现DebugEventListener但不确定我是否在正确的轨道上。如果您知道如何克服这个问题,请告知。

由于

1 个答案:

答案 0 :(得分:0)

我能够解决这个问题。在以编程方式关闭eclipse之前,我没有终止调试目标。您可以使用以下代码执行此操作:

    // debugTargets is the list of targets that can be updated when ever a new debug target is created.
    for (IDebugTarget target : debugTargets) {
          try {
                target.disconnect();
                target.terminate();
            } catch (DebugException e) {
                //handle the exception
            }
     }
     debugTargets.clear();