Debug remotely with Eclipse

To debug with eclipse to remote server follow below instructions

In the menu Run –> Debug configurations…

In the window popup select Remote Java Application

Right click, then select New

On the right a new fieldset appears

In the Project field browse the java project to attach

In the Connection Type field:

  • Select “Standard (Socket Attach)” – int the 99% of cases -, if you want to attach your eclipse to a server (which listen on a ip and port). In this case you should specify the IP/name and the port of the server you want to attach
  • Select “Standard (Socket Listen)”, if you want to be the host, listening just on a port (and on your ip). In this case you should just specify the port and the connection number you want to allow. Of course the machine is the same of eclispe running instance

The listening port, in both case (local and remote), must be preconfigured setting, as jvm parameters, the following:

-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=4000

  • The -XDebug parameter enables debugging
  • The -Xrunjdwp parameter loads the JPDA reference implementation of JDWP
  • Debugging, in the example, is enabled on port 4000

The JDWP protocol is the protocol used to debug with a remote debugger.

For example, in WebLogic server, to allow a debug socket listener, in the file “startWebLogic.cmd” add to the JAVA OPTIONS:

set JAVA_OPTIONS=-<others params> Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=n

The -Xnoagent parameter disables the default debug agent

Just a little notice: if you want to debug clustered application, you have to attach the debug ide to all clustered servers, otherwise you need to be lucky to get the request to your debugged server

Curiosity: default debug port on weblogic 12.1.3 is 8453


Add Your Comment: