Unable to debug in Java with eclipse

后端 未结 11 893
情话喂你
情话喂你 2020-12-03 06:55

I am trying to debug a simple Java application on my machine using Eclipse as an IDE. When I try to debug the application by entering the Debug Perspective, I set a breakpoi

相关标签:
11条回答
  • 2020-12-03 07:32

    Continuing @gonadarian's answer, it seems Eclipse uses port 127.0.0.1 for debug purposes. This port is also called localhost. The way this error can be removed is by ensuring that there are no processes or services running on the above ports. The way to do this, on Linux is:

    1. As root, enter the command:
      netstat -tulpn | grep 127.0.0.1

    2. If there are processes running on the above port, it will show up in the format:
      process_id/process name.

    3. Kill the above processes like so: kill -KILL process_id

    4. Restart the computer for these changes to take effect. The error should no longer occur.

    0 讨论(0)
  • 2020-12-03 07:36

    Had same problem, but the solution was to run the application with -server=y option and not with -server=n.

    Before:

    java -agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=localhost:5005 
    

    After:

    java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=localhost:5005
    
    0 讨论(0)
  • 2020-12-03 07:39

    Looks like the same problem as here. A reboot of the pc fixed the problem there. I haven't found any other solutions.

    0 讨论(0)
  • 2020-12-03 07:40

    I was seeing an error while using the -X format:

    java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=4000,suspend=n myapp
    

    The error went away when I switched to the newer format:

    java -agentlib:jdwp=transport=dt_socket,server=y,address=4000,suspend=n myapp
    
    0 讨论(0)
  • 2020-12-03 07:42

    My case is I have a bunch of domains refer to 127.0.0.1 in hosts file, like this:

    127.0.0.1 localhost domian1.local domain2.local domain3.local

    one day I added another new domain to refer to 127.0.0.1. By mistake, I put the domain in front of "localhost", like this:

    127.0.0.1 domain4.local localhost domian1.local domain2.local domainx.local

    After this, I always got an alert window in eclipse while debugging:

    Cannot connect to VM com.sun.jdi.connect.TransportTimeoutException

    In console:

    ERROR: transport error 202: connect failed: Connection refused ERROR: JDWP: Failed to initialize transport via localhost:50470, trying localhost via 127.0.0.1:50470 FATAL ERROR in native method: JDWP No transports initialized, jvmtiError=AGENT_ERROR_TRANSPORT_INIT(197) ERROR: transport error 202: connect failed: Connection refused ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510) JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [../../../src/share/back/debugInit.c:690]

    The solution is keep "localhost" at the first position all the time.

    127.0.0.1 localhost domian1.local domain2.local domainx.local domain4.local

    0 讨论(0)
  • 2020-12-03 07:42

    What solved for me was deleting the entire domain1 folder inside the domains folder on glassfish main folder. Eclipse will ask you to recreate a domain and then everything works again.

    0 讨论(0)
提交回复
热议问题