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 the Default Server for your node in the topology view on the left side of the console, and then select the JVM Settings tab in the right side of the console:

  3. Click the Advanced JVM Settings pushbutton and then, in the Advanced JVM Settings dialog box, select the Enable IBM Distributed Debugger checkbox:

    You will be prompted with a Confirm dialog message, asking you if you would like to enable OLT. Click Yes to enable OLT:

    The entry in the Advanced JVM Settings dialog box 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 in the Source Path. For this sample, 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, and then click Apply in the JVM Settings tab to save your changes.

  4. To see the OLT settings, select the Services tab:

    Select the Object Level Trace Service and then click Edit Properties.

    In the OLT server host field, specify the OLT host by entering the name of the machine where you will be running the OLT tool. The default value is localhost. The OLT server port should not be changed from its default of 2102, unless there is a port conflict (see the Note below). If you do not need to change any of the OLT properties in the Object Level Trace dialog box, click Cancel. If you do change any of the OLT properties, click OK and then Apply to save your changes.

  5. Start the Default Server by right-clicking on it and selecting Start from the pop-up menu.
  6. Once you have started 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.

  7. 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:

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

  9. 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:

  10. 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:

  11. 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.

  12. 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:

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

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

  14. You can now choose to step over, step debug, run, and so on. If you click Run, then HitCount should run to completion. Note that your browser may have timed out by this time. For information about increasing browser timeout, please see OLT Troubleshooting - Browsers in the OLT online documentation.

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