JBoss Application Server Remote Debugging from Eclipse

Eclipse and JBoss supports standard debug mechanism: JPDA. Here is how to connect both and debug web application developed in Eclipse, deployed on JBoss.

Debugging gives you possibility to stop your webapp execution at any point you want - just by setting breakpoints in eclipse, that works just like breakpoints in standalone apps - stops execution at specific line of code.

1. Turn on debugging in JBoss: set JAVA_OPTS in your operating system. You can do it in two ways:

  • uncomment line in JBoss run.bat file - just find in this file line, where entry similar to this appears, and uncomment it, restart JBoss:
    rem # Sample JPDA settings for remote socket debugging
    set "JAVA_OPTS=%JAVA_OPTS% -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"
    

    (various JBoss versions can have this line located in various places. for example in JBoss 5.1.0 it is in run.conf.bat file somewhere near line 51).

  • or you can execute command in command line:
    set "JAVA_OPTS=%JAVA_OPTS% -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"
    
    restart JBoss if needed

2. Set up Eclipse

Creating a new debug configuration by going to Run > Debug Configurations…

Debug Configurations

Create new "Remote Java Application" config, then in the toolbar up top, click on the new icon. This will give you a new debug configuration. On the right side, name it however you like. Then, change the port to 8787 and the host to where ever your JBoss installation is running. I'm running mine on the same machine that I am debugging on, so I leave it as localhost. Hit the Debug button:

Config Remote Java Application

You'll need to switch to the debug view to see all of your tools. To do so, go to Window > Show View > Other…, type in "debug" in the filter box and select the debug view. You should now see a JVM with a list of a bunch threads. If you don't see any threads, make sure that JBoss is running and that you followed the steps above correctly.

If all went well, you can now set break points in your code and they should show up automatically in the debugger.

Comments

Popular posts from this blog

Reduce TIME_WAIT Socket Connections