Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to have Eclipse Remote Debugger keep listening on port until a JVM finally connects?

I have a complicated application with several different JVMs.

JVM 1 does about 5 minutes of work and then fires off another JVM2 to do some extra work.

I want to Debug JVM2. So I turn on a remote socket debugger on JVM2's startup script:

-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000

And I set up my Eclipse Remote Debug Session like this:

Connection Type: Standard (Socket Attach), Host: localhost, Port: 8000

If I wait for JVM2 to start, then launch the debugger, it works fine.

However it is REALLY hard to pay enough attention to click the debugger after 5 long minutes of waiting.

If I launch the remote debugger before JVM2 is on... I get

Failed to connect to remote VM. Connection refused.
Connection refused: connect

Is there someway to have the Remote Debugger continuously try to connect?

I tried to use the Eclipse Remote Debug Connection Type: Socket Listen but this blocks the port and JVM2 gives this error on startup:

FATAL ERROR in native method: JDWP No transports initialized, jvmtiError=JVMTI_ERROR_INTERNAL(113)
ERROR: transport error 202: bind failed: Address already in use ["transport.c",L41]
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510) ["debugInit.c",L500]
JDWP exit error JVMTI_ERROR_INTERNAL(113): No transports initialized

How can I have the remote debugger try over and over and over again?

like image 358
Nicholas DiPiazza Avatar asked Aug 19 '14 21:08

Nicholas DiPiazza


People also ask

How do I keep debug points in Eclipse?

To define a breakpoint in your source code, right-click in the left margin in the Java editor and select Toggle Breakpoint. Alternatively, you can double-click on this position. The Breakpoints view allows you to delete and deactivate Breakpoints and modify their properties.

How do you set the JVM property of the server to debug?

Enable JVM DebuggingClick Java > JVM Settings tab. Under Debug Java Settings, select the Enable Debug checkbox. Provide JVM options as necessary by clicking the New button. If you substitute suspend=y, the JVM starts in suspended mode and stays suspended until a debugger attaches to it.

How does remote JVM debug work?

How Does Remote Debugging Work? The core principle of remote debugging is to establish a connection with the server hosting the back-end or front-end of the web application. This connection gives developers complete access to the machine on which the server is running.


1 Answers

Turning comment into answer for folks that come by later:

It's possible to specify server=n in the -Xrunjdwp switch and have the debugee connect as a client to the debugger server.

To make this work, the debugger configuration should be set up with the "Socket Listen" option in eclipse like so:

Eclipse debugger configuration

Client can then be started with:

java -Xdebug -Xrunjdwp:transport=dt_socket,server=n,suspend=n,address=8000 -jar foo.jar

Or similar.

like image 95
clstrfsck Avatar answered Nov 16 '22 03:11

clstrfsck