Debugging with JDeveloper

An important feature of JDeveloper is its ability to debug EJBs running in either the embedded server or a remote application server. We'll take a brief look at local debugging here. For information about remote debugging, consult Oracle's JDeveloper documentation.

To debug a program, we first need to set one or more breakpoints in our program. For example, open HelloWorldClient.java by double-clicking on the filename in the System Navigator. Locate the following line:

 helloWorld = helloWorldHome.create(  ); 

Clicking on the number to the left of this line will set a breakpoint, indicated by a red dot that replaces the line number. Also set a breakpoint in our EJB, HelloWorldBean.java, at this line:

 return "Hello, world"; 

We'll need to restart the HelloWorld EJB with debugging options enabled. To do this, right-click on the HelloWorld bean and select Debug HelloWorld. This will start (or restart) the EJB in debug mode. Notice that we won't enter the EJB code until a client application invokes it. So next, right-click on HelloWorldClient.java and select Debug HelloWorldClient.java. This will start the application and stop at the first breakpoint.

Notice that, at this point, the debugging icons are active in the toolbar below the menu. Positioning the mouse pointer over each for a moment will cause a tool tip to appear, identifying its function and its associated shortcut key. These are:

  • Resume (F9) Causes program to restart.

  • Step over (F8) Executes current line of code; if it's a method, it calls it and returns.

  • Step into (F7) If current line of code is a method, moves cursor into the method called, opening the source file, if necessary, but does not execute it. If current line is not a method call, executes the statement.

  • Step out (Shift-F7) Executes to end of current method, returns to calling method, and stops execution there.

  • Step to end of method Executes to end of current method, stops before returning to the calling method.

Another important tool is the SmartData view, available under the Tools menu item, which displays a tree view of objects and their attributes. You may wish to spend some time becoming familiar with this and other debug tools.



Java Oracle Database Development
Java Oracle Database Development
ISBN: 0130462187
EAN: 2147483647
Year: 2002
Pages: 71

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net