Remote debugging with Eclipse can be useful in many cases, especially if the server you'd like to debug isn't running through Eclipse, either locally or remotely. The following steps will configure remote debugging for JBoss. You'll need to adjust them a bit for other servers.
Changes to Server
- Locate the bin folder of the server you are running
- Add the following JAVA_OPTS setting to run.bat
- set JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n %JAVA_OPTS%
- Relaunch your server
In Eclipse
- Launch the Debug Configurations window (Run -> Debug Configurations)
- In the Debug Configurations window, create a new Remote Java Application
- Name: Enter name for the new configuration
- Connection Type: Standard (Socket Attach)
- Host: Enter IP address server is at
- Port: Port number specified in JAVA_OPTS above (This example uses 8787)
- Attach the source code that's running on the remote server:
- In the Source tab, click Add...
- Select Java Project and click OK
- Add the following projects:
- com.elasticpath.connect
- com.elasticpath.cm
- com.elasticpath.search
- com.elasticpath.sf
- Click Apply
- Click Debug
- At this point, if you are in the Java Perspective in Eclipse, you won't see anything different
- Change perspectives by going to Windows -> Open Perspective -> Others...
- Select Debug and click OK
Now you're ready to debug JBoss!
To debug, simply set breakpoints in parts of the code you're interested in and debugging is exactly the same as if the server was running within Eclipse!
For more information, you can refer to the following links: