Saturday, 5 March 2011

Configuring Debugging on a Weblogic Server

One of the useful and really speedy things yon can do is to debug and step through EJB code that is deployed on your Weblogic server as your integration tests are running. Doing this sorts out all kind of problems very quickly. To do this you need to modify your setDomainEnv.cmd file and setup a remote debugger on Eclipse.

Setting Up setDomainEnv.cmd
Near the top of your file add the following line to enable debugging.

echo ------------------------------------------------------------------
echo Setting Debug to true
set debugFlag=true
echo ------------------------------------------------------------------

Locate the following line locate further down the file and make a note of the port number:

rem set the port number
if "%DEBUG_PORT%"=="" (
            set DEBUG_PORT=8453

Setting up a remote debugging session
The next step involves connecting your Weblogic server to Eclipse.

  • After making the changes listed above restart your Weblogic server.
  • Run Eclipse
  • Click on the down-arrow by the Debug button and select ‘Debug Configurations...’ to display the following dialogue box.

  • Scroll down to ‘Remote Java Application’, right click and select ‘New’.
  • The dialogue box will change allowing you to setup your remote connection:
  • Choose a sensible name such as: ‘My Remote Debugging Session’
  • Remembering the port number from the previous section, type it into the ‘Port:’ edit box.
  • Select ‘Apply’ to save the settings or ‘Debug’ to save and start debugging now.
  • (Note: it doesn’t seem to matter which project you select.
If you chose ‘Debug’ then at this point, not a lot appears to happen, but if, after a few seconds, you switch to the ‘Debug’ perspective you’ll see your debug process running:

To test the set up add a break to or two to one of your classes and then run your integration tests and watch it break on your breakpoint inside the EJB.
To disconnect eclipse from your Weblogic server, kill your ‘My Remote Debugging Session’ from the Debug window.


Javin @ Basic Tutorials on FIX Protocol said...

I mostly use eclipse for remote debugging . its very easy to setup and its very useful for troubleshooting production issues on large enterprise application, specially if your application is live and you don't have proper development environment setup in your Dev box.

Roger Hughes said...

Quite agree that eclipse debugging is very easy to setup and very useful. I think that the point I really wanted to note was the need to enable the debug port on the Weblogic Server, which needs to be a config change followed by a restart. In hindsite, perhaps the blog should have been titled "Configuring eclipse Debugging on a Weblogic Server"

Anonymous said...

A great article indeed on remote debugging. Those who are into remote server management will surely find this helpful. Thank you for posting.