SteveG
SteveG

Reputation: 91

Debugging Java process using IntelliJ - connects to socket but not to target VM

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: '<PC_NAME>: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 <PC_NAME>: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:

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

https://bugs.java.com/bugdatabase/view_bug?bug_id=6547438

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

Upvotes: 2

Views: 32692

Answers (1)

Peter Lawrey
Peter Lawrey

Reputation: 533740

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?

Upvotes: 1

Related Questions