Remote debugging in JBoss

Have you ever wished you could debug your war project in Eclipse while it was deployed and running on JBoss? This is called remote debugging, and here’s how you set up to do it (on JBoss 4.2.2.GA running on Java 5, anyway):

  1. Make a backup copy of your current JBoss run.bat
  2. Open run.bat and find the lines that look like this:
    rem JPDA options. Uncomment and modify as appropriate to enable remote debugging.
    rem set JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y %JAVA_OPTS%
  3. Uncomment the second line, and save.
  4. Start Jboss. (It won’t do much until you connect a debugger to it.)
  5. In Eclipse, open your project, and on the toolbar click on the debugger bug arrow, then Open Debug Dialog.
  6. Choose Remote Java Application, right-click, New… and update the port to the address in the line you uncommented (possibly 8787).
  7. Click Debug
  8. Set a breakpoint somewhere in your code or a library that has source attached
  9. Exercise your project (via a web service, for instance) and when it hits one of your breakpoints, it will break in Eclipse.

Note to self: Avoid remote debugging for my own code — I should be adding log messages instead!


One thought on “Remote debugging in JBoss

  1. Another tip is – don’t leave the debugger connected to the test application when you go out to the lunch :P Your co-developer/tester can be a bit confused :)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.