jdb fails to connect to running java application over sockets

I'm trying to use jdb to connect to a running instance of a java program.

If I use dt_shmem:

> java -agentlib:jdwp=transport=dt_shmem,address=shmem,server=y,suspend=n JDBTest

>jdb -attach shmem

Set uncaught java.lang.Throwable

Set deferred uncaught java.lang.Throwable

Initializing jdb ...

> quit

works fine.

If I use dt_socket, jdb crashes:

> java -agentlib:jdwp=transport=dt_socket,address=9000,server=y,suspend=n JDBTest

P:\workspace\JDBTest>jdb -attach 9000

java.io.IOException: shmemBase_attach failed: The system cannot find the file specified

at com.sun.tools.jdi.SharedMemoryTransportService.attach0(Native Method)

at com.sun.tools.jdi.SharedMemoryTransportService.attach(SharedMemoryTra

nsportService.java:90)

at com.sun.tools.jdi.GenericAttachingConnector.attach(GenericAttachingCo

nnector.java:98)

at com.sun.tools.jdi.SharedMemoryAttachingConnector.attach(SharedMemoryA

ttachingConnector.java:45)

at com.sun.tools.example.debug.tty.VMConnection.attachTarget(VMConnectio

n.java:358)

at com.sun.tools.example.debug.tty.VMConnection.open(VMConnection.java:1

68)

at com.sun.tools.example.debug.tty.Env.init(Env.java:63)

at com.sun.tools.example.debug.tty.TTY.main(TTY.java:964)

Fatal error:

Unable to attach to target VM.

It looks like jdb is trying to connect over shared memory instead of using sockets.

Trying jdb -attach localhost:9000 has the same effect.

I can however connect to the running Java program using the Eclipse debugger using a remote configuration.

What can I do that jdb will use sockets?

I'm using Windows 2000 SP4 and Java 1.5.0_07.

Many thanks in advance

Thomas

[1820 byte] By [Th.Maucha] at [2008-1-6]
# 1

jdb -help says:

-attach <address>

attach to a running VM at the specified address using standard connector

On Windows the 'standard', ie. default, connector uses the shared memory transport.

To connect to a socket, you need to tell jdb to use the socket attaching connector, ie

jdb -connect com.sun.jdi.SocketAttach:port=9000

It is hard to remember the names and params of all the connectors. You can do

jdb -listconnectors

to refresh your memory.

HTH.

rod37roda at 2007-7-14 > top of java,Core,Monitoring & Management...
# 2
Many thanks.
Th.Maucha at 2007-7-14 > top of java,Core,Monitoring & Management...