JBoss AS 7 Debugging With Eclipse

If you have ever wanted to debug application code running on a instance of JBoss then this post is for you. This information is in various places on the Net, but I thought I would pull it together in one spot. That’s how I roll.

First off, I use JBoss EAP 6.1 (AS 7) and Eclipse Juno. These instructions will probably work for you should your versions be different. Just wanted to get that out of the way.

Next, You will need to start JBoss with a few extra options to the JVM. You can set these either in standalone.xml, or via the JAVA_OPTS environment variable. The options look basically the same, but for this post I will use JAVA_OPTS. Read this post from the JBoss Community forum if you want to use standalone.xml to configure the JVM parameters.

Add this line to your existing JAVA_OPTS:

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

The port number (8787) above must match your Eclipse setup (see below).

Finally, you will need to tell Eclipse how to connect to the remote process. In Eclipse, click the Debug button’s drop-down arrow and select “Debug Configurations”.

  • In that dialog, navigate to “Remote Java Application” and click the “New” button.
  • Under “Project” select the project that contains the code you want to debug.
  • Under Connection Type make sure “Standard (Socket Attach)” is selected.
  • Under Connection Properties, make sure the host (e.g., localhost) and port (which must match the port spec in the JAVA_OPTS, in this case 8787) are set.
  • Click on the “Source” tab and add any projects containing code you want to debug (if there are other projects in your workspace that contain code other than the main project).
  • In the Common tab, under “Display in favorites menu” select the Debug icon and a handy dandy icon will appear in your Debug toolbar dropdown (the name will be the same as the Project setting from earlier).

If JBoss is already running (with the options set earlier) click Debug to attach. If not, start JBoss, then click Debug to attach.

Now you can set breakpoints, step through your code, etc.

Have fun!

–jsp

About these ads

One Response to “JBoss AS 7 Debugging With Eclipse”

  1. very informative and helpful. thanks for sharing
    http://www.techversys.com/what-we-do

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 64 other followers

%d bloggers like this: