h1

Remote Debug a web application using eclipse

November 26, 2007

Eclipse has become the defacto IDE to develop enterprise applications in java. The architecture provides capabilities to support new features by adding plugins for the same. And there are host lot of plugins available for eclipse. For more info click here . Inspite of providing lot of features, developers are not aware of them and hence dont use them to simplify tasks. One of the important aspects of enteprise web applications is debugging. This post will tell you on how to debug web applications using eclipse. The Application server used for this example is JBOSS 4.0.2. I hope the steps specified here would be similar when used with other applications servers.

First specify a breakpoint at which you want the run time execution to stop. You can do this in eclipse by double clicking on the left pane of java editor. Next go to JBOSS_HOME\bin. Open the run.bat file in notepad and search for “8787” . You would hit at a line like this

JBOSS run.bat

Delete the REM statement at the start of the line. By doing this you are enabling JBOSS to run in remote debug mode. Build your war file using MAven/Ant and deploy it in JBOSS_HOME\server\default\deploy folder.Save the run.bat file and double click on it to run JBOSS.

Now come back to eclipse. Once you have configured breakpoints in eclipse. Click on Run->Open Debug Dialog. Right Click on Remote Java Application and choose new. A new application based on the class name that contains break point is displayed. Now in Connection properties (right pane) specify the port 8787. A typical configuration for remote debug in eclipse looks like this :

Remote Debug Configuration in eclipse

You are done with all the settings. You just have to click on debug to start remote debugging your web application. Open the debug perspective if eclipse prompts you so. You can add break points dynamically, know values of variables at run time by right clicking on that variable and selecting watch. Remote debugging is very useful for a newbie in a project to learn about the flow of web application. Hope you find this post useful for your day-today project work.

TitBit to deploy web applications using maven : Developers need to redeploy their war files to JBOSS\..\deploy folder whenever they make changes to the code. This manual operation is tedious as the developer has to do three operations : Build the war file, copy to JBOSS\..\deploy and start the JBOSS server. The last two operation can be done through maven 2.x plugin for JBOSS. For more info about the plugin visit Maven-JBOSS-Plugin

Advertisements

3 comments

  1. Chweet! Was going to ask you to write this one.


  2. Can Maven-Jboss-Plugin posibly accept remote paths ?

    May be sthing like ,
    //192.167.1.55/../Library/JBoss/4.0.2


  3. Excellent question. I went through few articles and found that remotely deploying war file is possible.
    You need to specify the remote host name value in the hostName element and the correct port number in port element.
    PS: These two element are to be specified within configuration element



Leave a Reply

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

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

%d bloggers like this: