How do I get the Eclipse Remote Debugger to continue listening on the port until the JVM finally connects?

I have a complex application with several different JVMs.

JVM 1 takes about 5 minutes to work, and then starts another JVM2 to do the extra work.

I want to debug JVM2. Therefore, I turn on the remote socket debugger when running the JVM2 script:

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

And I configured my Eclipse Remote Debug Session as follows:

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

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

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

If I run the remote debugger before turning on JVM2 ... I get

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

Is it ever possible for a remote debugger to try to connect?

I tried using 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 remove the remote debugger again and again?

+6
source share
1 answer

Inclusion of a comment in the answer for people who come later:

You can specify server=n in the -Xrunjdwp switch and connect debugee as a client to the debug server.

To do this, you must configure the debugger using the "Socket Listen" option in eclipse, for example:

Eclipse debugger configuration

Then the client can be started using:

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

Or similar.

+6
source

Source: https://habr.com/ru/post/974055/


All Articles