InfoCenter Home >
6: Administer applications >
StockQuote tutorial: Using Debugger and OLT

6.7.sq: StockQuote tutorial: Using Debugger and OLT

StockQuote is one of the samples that ships with IBM WebSphere Application Server. It is installed if, during WebSphere Application Server installation, you choose to install the Samples. This tutorial demonstrates how to use the IBM Distributed Debugger and Object Level Trace (OLT) on the StockQuote sample, referring to screen captures from the administrative console (WebSphere Administrative Console) used with the Application Server Advanced Single Server Edition.

Let's begin.

  1. Start the Administrative Console:

  2. Select IBM Debug and OLT in the topology view on the left side of the console for the default server on your node:

  3. This will cause the IBM Distributed Debugger and Object Level Trace Settings page to display in the right-hand frame of the browser:

    Select the Enable Object Level Trace and Enable IBM Distributed Debugger checkboxes. In the Host Name field, specify the OLT Host Name by entering the name of the machine where you will be running the OLT tool. The OLT Port should not be changed from its default of 2102, unless there is a port conflict (see the Note below). The entry in the Source Path field indicates to the Debugger where servlet source files, EJB source files, and JSP files can be found. Use semicolons to separate all entries on the Source Path. For this sample, add the following to the source path:

    <WAS_ROOT>\installedApps\Samples.ear\Samples.war\StockQuote;<WAS_ROOT>\installedApps\Samples.ear\Samples.war\WEB-INF\classes\WebSphereSamples\StockQuote

    where WAS_ROOT is where WebSphere Application Server is installed (eg. c:\WebSphere\AppServer). Click OK when you are finished.

  4. To save your configuration, click Save and then click OK in the Save Configuration frame. At this point, you must restart the application server in order to pick up your changes:

  5. Once you have restarted the application server, start OLT by issuing the olt command at a command prompt. You will then see the following screen:

    Ensure that the Execution mode is set to Trace and debug. If it is not, click the drop-down list and select it. In the Debugger hostname field, specify the name of the machine where the debugger tool is located. Assuming for this example that the Debugger is installed locally, enter the host name of the machine on which you are working. Keep the Debugger TCP/IP port set to 8001 (change it only if port 8001 is already in use on your machine). Click Apply.

  6. Invoke the IBM WebSphere Application Server Samples and select the StockQuote sample. You will see the following in your web browser:

  7. Click Run this Sample. OLT will trace the initial calls to the StockQuote servlet and JSP:

  8. Your browser should then display the following:

  9. Let's enable step-by-step debugging now.

  10. In the browser, enter IBM in the Stock Symbol field and then click Submit. Because you selected step-by-step debugging mode, you will be asked if you want to step into every method that can be debugged. The first method is the doPost method of StockQuoteServlet. The following dialog box will be displayed:

  11. Highlight the doPost method and Click OK. This will cause the debugger to attach and suspend in the first executable line of the StockQuoteServlet doPost method:

  12. You can now choose to step over methods, step into others, or run the program. Click Run in the Debugger toolbar. Because OLT is in Step-by-Step mode, when it encounters the next method that can be debugged, it will ask you again (via the Method breakpoints dialog box) if you would like to step into the method:

  13. Let's step into the JSP, highlight the _jspService method in the Method Breakpoints dialog box, and click OK. Or, if you wanted to skip breaking into this method, click Cancel in the Method Breakpoints dialog box.

  14. The debugger will enter the JSP code, displaying the following:

  15. You can now choose to step over, step debug, run, and so on. If you click Run, then StockQuote should run to completion. Note, your browser may have timed out by this time. The Troubleshooting section of the OLT/Debugger documentation describes how to increase the browser timeout.

Note:

If you modify the Port in the IBM Distributed Debugger and Object Level Trace settings frame to a port other than 2102, you must start OLT and modify the OLT Server TCP/IP port accordingly. The OLT Server TCP/IP port is set in the Browser Preferences dialog box (accessed by selecting File > Preferences from the OLT menu bar and then selecting the OLT node). If there is a port conflict and you are unable to start OLT, go to the %userprofile%\DbgProf directory and modify the OLT_TRC_SRVAPP_PORT in the dertrenv.dat file accordingly.

Go to previous article: Tutorials Go to next article: HitCount tutorial: Using Debugger and OLT

 

 
Go to previous article: Tutorials Go to next article: HitCount tutorial: Using Debugger and OLT