使用IntelliJ调试Java进程 - 连接到套接字但不定位到VM [英] Debugging Java process using IntelliJ - connects to socket but not to target VM

查看:1259
本文介绍了使用IntelliJ调试Java进程 - 连接到套接字但不定位到VM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在解决了 - 看到问题的结束。



我试图使用IntelliJ Community Edition的调试器调试Java进程。套接字正在侦听 - 但是当我尝试连接调试过程时,显示以下
'连接到目标VM,地址:':8003',transport:'socket'
它从不将连接虚拟机和我无法调试。



我已经转到Windows 7 64位PC - 在我的旧XP机器上,可以连接和调试这个Java进程(这是一个应用程序我建立和维护)。



它不会失败,标准的连接拒绝:连接错误,如果没有进程连接到您会得到。 Netstat还显示端口在应用运行时正在收听。



TCP 0.0.0.0:8003:0 LISTENING



Debug args for the app
-Xrunjdwp:transport = dt_socket,server = y,suspend = n,address = 8003
-Xdebug



如果我尝试从远程机器上的IntelliJ运行调试会话,我可以连接到本地机器上运行的进程并进行调试。
如果我在远程机器上运行Java应用程序,并在本地机器上使用IntelliJ,我可以进行调试。
只有我在同一台机器上运行和调试失败 - 不幸的是,这是几乎所有的时候我需要做的。



我发现的类似的问题是从2004年起,使用带有空格的文件路径,NetBeans,而不是IntelliJ。我已经重建并重新运行我的应用程序,确保路径中没有空格或下划线,没有快乐。



我的intelliJ调试设置是在套接字上调试本地机器,连接模式端口8003 - 抱歉,作为一个新用户我无法附加图像。



我尝试的其他事情:



  • 更改JRE版本

  • 使用共享内存而不是套接字传输调试

  • 我没有重新安装IntelliJ - 我正在使用相同的建立作为我没有这个问题的其他开发者(10.5 IC 107-105)。

  • 更改调试进程侦听的端口(从8003到其他各种,根据netstat未使用)

  • 我尝试使用PC名称,IP地址和localhost在调试设置中引用PC。

$ b $卡住了。任何帮助非常感谢。

感谢
史蒂夫



已解决



一天没有解决,然后我发现答案20分钟后发布。一个无效的JNI签名字符,只在调试时提取。通过在调试时添加此参数来解决。



-Dcom.sun.xml.bind.v2.bytecode.ClassTailor.noOptimize = true



http://bugs.sun.com/bugdatabase/view_bug .do?bug_id = 6547438



感谢您的帮助。仍然不知道为什么它会在远程调试但不在本地以前工作。

解决方案

这听起来像一个奇怪的防火墙问题。



似乎您应该可以尝试 telnet localhost 8003 ,它应该会失败。这意味着没有任何东西可以连接到该端口上的您的应用程序。



编辑:如果共享内存也可以工作,并且无法通过telnet连接,则会出现问题您正在运行应用程序。



如果应用程序未运行,您将收到此类错误。



你可以尝试从IntelliJ调试一个简单的程序吗?


Now resolved - see end of question.

I am attempting to debug a Java process with IntelliJ Community Edition's debugger. The socket is listening - but when I try to connect the debug process shows the following 'Connecting to the target VM, address: ':8003', transport: 'socket' It never makes the connection to the VM and I cannot debug.

I have moved to a Windows 7 64 bit PC - on my old XP machine and could connect and debug this Java process (it's an app I build and maintain).

It does not fail with the standard "Connection refused: Connect" error that you would get if no process was there to connect to. Netstat also shows the port is listening when the app is running.

TCP 0.0.0.0:8003 :0 LISTENING

Debug args for the app -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8003 -Xdebug

If I attempt to run the debug session from IntelliJ on a remote machine, I can connect to the process running on my local machine, and debug. If I run the Java app on a remote machine, and use IntelliJ on my local machine, I can debug. It is only if I run and debug on the same machine that it fails - unfortunately this is what I need to do almost all the time.

The only similar issues I have found are from 2004, to do with file paths with spaces, and were NetBeans, not IntelliJ. I have rebuilt and rerun my app ensuring no spaces or underscores in the path, no joy.

My intelliJ debug settings are to debug my local machine on socket, attach mode port 8003 - sorry as a new user I can't attach an image.

Other things I have attempted:

  • Changing JRE versions
  • Debugging using shared memory rather than socket transport
  • I have not re-installed IntelliJ - I am using the same build as my fellow devs (10.5 IC 107-105) who don't have this problem.
  • Changing the port the debugging process listens on (from 8003 to various other, unused according to netstat)
  • I have tried using PC name, IP Address and 'localhost' to refer to the PC in the debug settings.

Stuck. Any help much appreciated.
Thanks Steve

Resolved

Well, a day of failing to solve then I find the answer 20 mins after posting. An invalid JNI signature character, only picked up when debugging. Solved by adding this arg when debugging.

-Dcom.sun.xml.bind.v2.bytecode.ClassTailor.noOptimize=true

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6547438

Thanks for the assistance. Still don't know why it would work when debugging remotely but not locally before.

解决方案

It sounds like a strange firewall issue.

It appears that you should be able to try telnet localhost 8003 and it should fail. This means nothing can connect to your app on that port.

EDIT: If shared memory does work either and you cannot connecft it via telnet, there is a problem with the way you are running the app.

You will get this type of error if the application is not running.

Can you try debugging a simple program you lauch from IntelliJ?

这篇关于使用IntelliJ调试Java进程 - 连接到套接字但不定位到VM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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