Tracing and debugging a Java client and Business Object (Windows NT/2000)

Objective
The following information applies to Windows.The objective of this sample is to trace and debug a distributed application in which the client code and business object are written in Java. Both are installed on Windows NT/2000.

Before You Begin
You must complete the steps to compile and install the Policy sample for Windows NT/2000, including the Java client application (as explained in the Preparing for the OLT tutorials).

For this exercise, a single Windows NT/2000 machine is running OLT, the debugger, and your client and server applications, as follows:

npoolt1d.gif (2998 bytes)

Description
In this exercise, you will complete these steps:

  1. Start Object Level Trace.
  2. Run your application to produce a trace.
  3. Set a breakpoint on the business object.
  4. Prepare for tracing and debugging.
  5. Rerun your sample for tracing and debugging.
  6. Debug the server method.
  7. Step from server to client code for tracing and debugging.
  8. Disable the breakpoint and run the application to completion.

Sample instructions
Follow these steps to perform the tracing and debugging for this scenario:

  1. To start Object Level Trace on your Windows NT/2000 system, type olt in a command window . OLT starts. Make sure that Trace only is selected for Execution mode for Default settings in the OLT Viewer window. If you have to change the setting, click Apply.
  2. Run your application to produce a trace.
    1. From a command prompt, change to the directory where you compiled the Java client version of the Policy sample
    2. Enter the following command:
      java 
      -Dcom.ibm.CORBA.EnableApplicationOLT=true 
      -Dcom.ibm.CORBA.OLTApplicationHost=<OLT_Server_Host> 
      -Dcom.ibm.CORBA.OLTApplicationPort=<OLT_Server_Port> 
      -DOLTClient=true 
      -classpath "d:\cbroker\samples\InstallVerification\ProgrammingModel\
      BusinessObjects\Policy\Working\NT\TRACE_DEBUG\jcb\jcbPolicyC.jar;
      d:\cbroker\lib\somojor.zip;D:\WebSphere\AppServer\lib\dertrjrt.jar;%CLASSPATH%" 
      -Xbootclasspath/a:"%JAVA_HOME%\lib\tools.jar;D:\WebSphere\AppServer\lib\derdbpw.jar" 
      PolicyApp

      where:
      <OLT_Server_Host> is the fully qualified name or TCP/IP address of the machine running your OLT server
      <OLT_Server_Port> is the port where the OLT server listens for connecting OLT clients (default 2102)

    3. A trace is created, showing the calls from your client to the Policy and PolicyHome objects on the server, similar to the following:

      npnoltgn.gif (18721 bytes)

  3. Set a breakpoint in the trace.
    1. In the trace, select the server event that represents the getpremium method.
    2. Select the event, right-click, and select Add to Method Breakpoint List.
  4. Prepare for tracing and debugging.
    1. From the OLT Viewer's Options menu, deselect Step-by-step Debugging Mode.
    2. In the OLT Viewer's Client Controller page, select Trace and debug for Execution mode and click Apply.
  5. Rerun the sample for tracing and debugging.
    From a command prompt, change to the directory where you compiled the Java client version of the Policy sample.
    1. Enter the following command:

      JDK 1.2.2+JPDA

      java -Xdebug -Xnoagent Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=<JVM_port> 
      -Djava.compiler=NONE 
      -Xbootclasspath/a:"<WebSphere_jdk>\lib\tools.jar;<WebSphere>\lib\derdbpw.jar"
      -Denv.class.path=%DEBUG_CP%
      -Dcom.ibm.debug.jdwpport=<JVM_port> 
      -Dcom.ibm.CORBA.requestTimeout=0
      -Dcom.ibm.CORBA.EnableApplicationOLT=true
      -Dcom.ibm.CORBA.OLTApplicationHost=<OLT_Server_Host>
      -Dcom.ibm.CORBA.OLTApplicationPort=<OLT_Server_Port>
      -DOLTClient=true
      -classpath "d:\cbroker\samples\InstallVerification\ProgrammingModel\
      BusinessObjects\Policy\Working\NT\TRACE_DEBUG\jcb\jcbPolicyC.jar;
      d:\cbroker\lib\somojor.zip;D:\WebSphere\AppServer\lib\dertrjrt.jar;%CLASSPATH%" 
      -Xbootclasspath/a:"%JAVA_HOME%\lib\tools.jar;D:\WebSphere\AppServer\lib\derdbpw.jar" 
      PolicyApp

      Where:

      • <WebSphere_jdk> is the where the WebSphere JDK is installed, for example, c:\WebSphere\AppServer\java.
      • <WebSphere> is the where the WebSphere AppServer is installed.
      • %DEBUG_CP% has the location of the Java source code.
      • <OLT_Server_Host> is the fully qualified name or TCP/IP address of the machine running your OLT server
      • <OLT_Server_Port> is the port where the OLT server listens for connecting OLT clients. The default is 2102.
      • <JVM_port> is the port for the JVM. It is a free port number.

      If you are using other JDK levels, see JDK 1.1.x and JDK 1.3.x for the appropriate java command.

  6. Debug server method.
    1. The program halts at your breakpoint and the debugger prompts for the source file location. Follow instructions to specify the source file.
    2. The debugger opens and steps into the getpremium method on the server:

      npnoja2a.gif (4573 bytes)

  7. Step from server to client code for tracing and debugging.
    1. Click Step over once. This creates another debugger page for the client, and shows you the client stub code, at the step immediately past the call to the getpremium method:

      npnoja3a.gif (4471 bytes)

    2. On the client debugger toolbar, click Step return once. The following client code is shown:

      npnoja4a.gif (3420 bytes)

  8. Disable the breakpoint and run the application to completion.
    1. In the OLT window, Select Breakpoints > List method breakpoints. A dialog box opens.
      From the Available method breakpoints list, select the getpremium breakpoint and click Disable.
    2. In the Debugger window, click Run. The application runs to completion.

Important Note:
While running your application, do not close the debugger window you are using to debug server code. Doing so shuts down the application server (this is a Windows NT/2000 limitation). When you finish debugging, stop your application server using System Manager, then close the OLT window.

ngrelr.gif (548 bytes)
Component Broker Object Level Trace examples
OLT Overview