Java remote debugging, eclipse can't stay connected

Refresh

April 2019

Views

1.7k time

1

I have an issue when I try to remote debug via eclipse.

These are the arguments I use:

-Xdebug
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=4044

I also tried setting the address to 0.0.0.0:4044, using this:

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

I have tried all sorts of setups, setting suspend to 'y' made the application wait for a debug connection, as soon as it got connected the application continued but a connection couldn't be made.

When I try to connect from eclipse it just times out.

If I run a netstat -tulpn | grep 4044 I get this output:

tcp        0      0 0.0.0.0:4044                0.0.0.0:*                   LISTEN

After the connection attempt sometimes it stops listening on the port.

Any ideas?

3 answers

0

Adding the following in the ntServiceWrapper.conf worked for me

wrapper.java.detect_debug_jvm=TRUE

# Number of seconds to allow between the wrapper pinging the JVM and the response.
wrapper.ping.timeout=0
4

Normally on the listening process I use:

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

You have to start the process correctly
E.g. for tomcat

    JPDA_OPTS="-agentlib:jdwp=transport=dt_socket,address=4000,server=y,suspend=n"
    catalina.sh jpda start

using a wrapper as tanuki:

http://wrapper.tanukisoftware.com/doc/english/prop-java-detect-debug-jvm.html

If you read it

The Wrapper has several features which are designed to detect when a JVM has frozen, or otherwise become unstable. Normally these features should all be left enabled. However, when a JVM is connected to a debugger, it is common for the JVM to intentionally be frozen as various debugging operations take place. In these cases, the Wrapper would normally think the JVM was frozen, and kill and restart it in the middle of a debug session. The Wrapper works around this problem by checking the configured Java command line and ignoring certain timeouts when it detects that a debugger is in use. This property makes it possible to enable or disable this debugging check. The default value is "TRUE", which will detect the debugging and ignore certain timeouts. Example: (detect the debugging) wrapper.java.detect_debug_jvm=TRUE

(...)

In your case I think you just need

    wrapper.java.detect_debug_jvm=FALSE

Let me know if I am right cause I cannot test it.

0

I had a similar issue when I needed to debug in on OSGI server.

There were a combination of trouble and after solving them I could debug well.

I answered it in this thread

By the way, you can try by stopping your firewall, in case of iptables you have to do:

service iptables stop

You can try by modifying your debugging port and trying to access it. Another test you can do is to debug with another tool like JDebugTool to check if you Eclipse is the problem.

If you use Ant, verify you have your javac configured well:

<javac srcdir="..." destdir="..." classpathref="..." debug="true" debuglevel="lines,vars,source" />

In Eclipse verify you have this:

windows > preferences > Java > compiler -> "Classfile generation" -> check "Add line number attributes to generated class file"

Hope to help!