Chapter 12 Creating CORBA-Java Components
Debug Java components
You can debug Java components that are executing in the Jaguar
server.
Before you start
Debugging Java components requires the following:
- Java debugging must be enabled for your Jaguar server. Display
the properties window for the server (right-click and select Server
Properties from the pop-up window), display the Debug tab, and select
the Enable Java Debugging option. The change takes effect the next
time you start the debug version of the Jaguar server.
- The debug version of the Jaguar server must be running.
On NT, use either of the following to start a debuggable server:
- Launch the Jaguar Server (dev) icon
- Run the script %JAGUAR%/bin/serverstart_dev.bat.
On UNIX, run the script $JAGUAR/devbin/srvstart_dev.
- You need a JDK-1.1-compatible Java debugger that
supports remote debugging, such as PowerJ or the JDK 1.1 jdb tool.
- Component class files must include symbol information
for fields and local variables. If you are compiling with javac,
components must be compiled with the
-g
option.
If you use a Java IDE, set the equivalent option to build debuggable
class files.
- Source files must be available to the debugger.
The required location for source files depends on your debugging
tool:
- For jdb, source files
must be on the Jaguar server host, in the directory from which the
corresponding class file is loaded.
- PowerJ uses local source files from the project
directory.
- For other IDE debuggers, consult the IDE documentation
for source file requirements when you are debugging remotely.
Steps to debug an executing component
Follow the steps below to debug Java components.
The included examples use jdb and
the Sybase Virtual University Enrollment_Java component.
-
Make sure that you have enabled Java debugging
in the Jaguar server and that you are running the debug version
of the server (see "Before you start"). Make sure no one else is debugging
components using the same server (the server-side debugger supports
only one remote-debugger connection at a time).
-
Find the remote-debugger password in the server's
console window. For example, the password is
k53js
in
the output reproduced below:Agent Password=k53js
You will need this password to connect to Jaguar with your
debugger.
-
Start your debugger and connect to Jaguar. For example,
with jdb:
jdb -host localhost -password k53js
-
Once connected, you can specify breakpoints for the
debugger to stop at in your component implementation. Set the breakpoint
before running any client applications that will exercise the target
line of code. For example (the following must be entered on one
line):
stop at Sample.SVU.javaComp.
Enrollment_Java.Enrollment_JavaImpl:74
(This breakpoint corresponds to the CreateStudentRecord method
in the Enrollment_Java component.)
-
Run a client application that will invoke the target
component code. For example, to debug the CreateStudentRecord method
in the Java_Enrollment component,
run the SVU Java example client in your Web browser and create a
new student record on the login screen. In the debugger, you should
see some indication that the breakpoint has been reached.
You may need to change the debugger's active
thread before the component breakpoint is indicated. Jaguar runs
each Java component instance in a separate Java thread. The component
thread must be the active debugger thread in order to step through
the component's code. In jdb, use the threads command
to list the executing threads. You can then use the thread command
to switch to the thread that is running the component.
-
Once the breakpoint is tripped, you can step through
the code, inspect fields and variables, and so forth. For example,
in jdb:
Thread-21[1] where 6
[1] Sample.SVU.javaComp.Enrollment_Java.Enrollment_JavaImpl.
createStudentRecord (Enrollment_JavaImpl:74)
Thread-21[1] print student_id
student_id = 333-33-3333
Thread-21[1] cont
Debugging class loading and unloading problems
Jaguar Manager provides the following server properties to
log information about Java class loading and unloading.You can set
these properties on the All Properties tab in the Server Properties
dialog box:
Property
|
Description
|
com.sybase.jaguar.server.jvm.verbose
|
When this property is set to true
,
the server logs all Java classes that are loaded and the location
where each class file was read.
|
com.sybase.jaguar.server.jvm.verboseGC
|
When this property is set to true
,
the Jaguar server logs information when memory is freed by the Java
garbage collector.
|
The default for both properties is false
.
Copyright © 2000 Sybase, Inc. All rights reserved.
|
|