Debugging Remote Java Application
by, 11-05-2011 at 07:38 PM (1463 Views)
Debugging is very helpful is following the flow of an application and knowing what happens when. You get list of variables with their values and you can flow what exactly is happening. It really helps is identifying the problem areas. Debugging in Eclipse is really simple and easy. I assume that you have done debugging in Eclipse.
Debugging a J2EE application is a bit tricky since the application is deployed in web/application container. JBoss provides support for this. You have to edit
jboss\bin\run.bat file. Look for the following lines:
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%
Remove rem from the second line to activate remote debugging. Do change the port if you want to. This port will be used from Eclipse for remote debugging.
In the first part, I showed how to alter JBoss run.bat file for remote debugging. Once that is done, deploy your J2EE application and start the JBoss. You will note that on the JBoss console, the listener will start listening on port specified in run.bat.
Now is the time to start debugging from Eclipse. Open the Debug dialog and select 'Remote Java Application'. Create a new configuration. Select the project to debug and attach source code with it. In the connect tab, don't forget to put connection properties which comprises of Host and Port.
Once all the done, start debugging.
I hope this was useful.