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

6.7.hc: HitCount tutorial: Using Debugger and OLT

HitCount is an example servlet that installs by default with IBM Websphere Application Server. This tutorial demonstrates how to use the IBM Distributed Debugger and Object Level Trace (OLT) on the HitCount servlet, 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 the example, add the following to the source path:

    <WAS_ROOT>\installedApps\sampleApp.ear\examples.war;<WAS_ROOT>\installedApps\sampleApp.ear\examples.war\WEB-INF\classes

    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 HitCount servlet by typing its URL in a Web browser:

    http://<your_machine>/webapp/examples/HitCount

    OLT will trace the initial calls to the HitCount servlet and JSP:

    Your browser should now be displaying the following:

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

  8. In the browser, choose the Enterprise Java Bean radio button and Transaction Type None. Click the Increment button, and OLT will start tracing the events taking place:

    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 service method of HitCount. The following dialog box will be displayed:

  9. Highlight the service method and Click OK. This will cause the debugger to attach and suspend in the first executable line of the HitCount service method:

  10. 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. Indicate that you would like to skip breaking into the enterprise bean. An enterprise bean is displayed as two distinct objects in the trace: the enterprise bean object itself, and an object called the ProgrammingModel. The ProgrammingModel is an EJB Factory instance that is beyond application logic and is not intended to be debugged.

  11. To skip breaking into a method, click Cancel in the Method breakpoints dialog:

    The EJB trace lines in the trace are IncBean and ProgrammingModel, as shown:

  12. To break into the JSP, step into the _jspService method:

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

  13. You can now choose to step over, step debug, run, and so on. If you click Run, then HitCount 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: StockQuote tutorial: Using Debugger and OLT Go to next article: Backing up and restoring administrative configurations

 

 
Go to previous article: StockQuote tutorial: Using Debugger and OLT Go to next article: Backing up and restoring administrative configurations