Skip to main content

jdb fails to attach

Please note these forums are being decommissioned and use the new and improved forums at
1 reply [Last post]
Joined: 2011-08-18

This happens on fedora 17 using jdk 1.7 or 1.5. It doesn't happen on debian using a much earlier kernel. In fedora, I have selinux disabled and iptables rules flushed.

I'm trying to use a debugger that uses CommandLineLaunch connector and it fails to connect.

I see the same problem if I use jdb.

For example:

jdb -sourcepath . -classpath . test.Test

I think it's supposed to launch 2 VMs and attach the debugger to the debugee. But, it
waits and times out, reporting the same error message that I get from the debugger I'm trying to use:

VM start exception: VM initialization failed for: /opt/jdk1.7.0_04/jre/bin/java -classpath . -Xdebug -Xrunjdwp:transport=dt_socket,,suspend=y test.Test

ERROR: transport error 202: connect failed: Connection timed out
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)

Fatal error:
Target VM failed to initialize.

If I use two command line invocations:

java -agentlib:jdwp=dt_socket,server=y test.Test

it prints the port number that it's listening on, e.g.: 12345


jdb -attach 12345

Has the same error message.

If I use SocketAttach connector it works:

jdb -connector "com.sun.jdi.SocketAttach:hostname=localhost,port=12345"

Unfortunately, my debugger isn't using that connector.

So, looking at the problem further:

jdb -connect "com.sun.jdi.CommandLineLaunch:main=test.Test"

Has the same error message together with a command line showing that it's using the wrong port number (how would it know anyway).

If I correct the port in the command line:

java -Xdebug -Xrunjdwp=transport=dt_socket,address=,suspend=n test.Test

It says the handshake fails:

ERROR: transport error 202: handshake failed - connection prematurally closed
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)

Attempting to specify "options" for CommandLineLaunch fails to parse, or I don't know how to specify the sub-option:

jdb -connect "com.sun.jdi.CommandLineLaunch:main=test.Test,options=address="

Constructs an incorrect command line which fails:

/opt/jdk1.7.0_04/jre/bin/java address= -Xdebug -Xrunjdwp:transport=dt_socket,address=,suspend=y test.Test

What do you think the problem could be? Also, how does one specify the sub-options of the options option?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2011-08-18

Sorry to reply to myself, but I think I found the problem, but I don't know why it's happening.

I lied slightly in my posts by changing the address. It's actually using the dns name that my ISP gives to my router's external IP address, e.g. instead of or

So, of course there is indeed no debugger listening there. How can it be coming up with that hostname for my computer?