Example 14.4, “Debugging example” shows how to attach the Java debugger to an application running on ActiveSpaces® Transactions .
Example 14.4. Debugging example
// $Revision: 1.1.2.1 $
package com.kabira.snippets.reference;
/**
* Simple hello world snippet
* <p>
* <h2> Target Nodes</h2>
* <ul>
* <li> <b>domainnode</b> = A
* </ul>
*/
public class HelloWorld
{
/**
* Main entry point
* @param args Not used
*/
public static void main(String args[])
{
System.out.println("Hello World");
}
}
#
# NOTE: Remove the package statement from the HelloWorld.java snippet above
# to work with the example steps below.
#
#
# Compile the program using the native javac on the host machine
#
javac HelloWorld.java
#
# Excute the program against an ActiveSpaces® Transactions
node - assumes
# deploy.jar is in the local directory
# Notice that suspend=true is set on the command line to suspend main until the
# debugger attaches.
#
#
java -jar deploy.jar hostname=192.168.1.128 adminport=2001 \
username=guest password=guest suspend=true remotedebug=true HelloWorld
#
# The output from the ActiveSpaces® Transactions
node - the above command
# blocks waiting for the debugger to attach.
#
INFO: deploy.jar version: [core_linux081108]
INFO: JVM remote debugger agent running on [192.168.1.128:45871] ...
INFO: node version: [core_linux081108]
INFO: Running with suspend=true - the application will suspend execution before main() is called ...
Listening for transport dt_socket at address: 45871
#
# Execute jdb in another window using -connect to connect to the
# ActiveSpaces® Transactions
node
#
# NOTE: The port number is obtained from the above output.
#
jdb -connect com.sun.jdi.SocketAttach:hostname=192.168.1.128,port=45871
#
# Output from jdb command - enter cont at the prompt
#
Set uncaught java.lang.Throwable
Set deferred uncaught java.lang.Throwable
Initializing jdb ...
>
VM Started: No frames on the current call stack
main[1] cont
#
# Output in jdb window after cont
#
>
The application exited
#
# Output in java window after cont.
#
Hello World