Saturday, October 11, 2008

Debugging application server as remote application

The need was to debug Resin 3.1.0 in eclipse, however there's no plugin for Resin 3.1.0 in eclipse (at least until now) to my own amazement.
Fortunately, there's still a workaround which is to debug the application server as if it is a remote java application.

To do that, we need to add the parameter below before starting the server

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

(-Xnoagent already deprecated, we could remove it anyway, so why do I put it there? Just to let you know that it exists and if you still use JDK1.1 then use it otherwise loose it)

Adding the parameter above means that we could attach a debugger to localhost:12345 (assuming I'm debugging application server running at my computer), the address could be adjusted to a different port as long as the port is unused.

Then on the IDE of your choice (I've tried eclipse and netbeans), just open a remote debug session and put localhost as the host and 12345 as the port. If your IDE successfully attaching a debugger to the server, then all you need to do is set breakpoint(s) to your application code which was deployed to the server. Access the application and the server will be suspended when it arrives at the breakpoint set before.

That's all for now, any question just shoot.

Note : I'm not explaining all those parameters in detail, if you're interested, please visit this link.

No comments: