Java Troubleshooting Guide for HP-UX Systems

1. If the errfilename begins with the file separator character (“/”), it specifies an absolute
path. The JAVA_CORE_DESTINATION environment variable is not used for the
errfilename.
2. If the errfilename contains the file separator character (“/”), but does not begin with one,
it specifies a relative path ($JAVA_CORE_DESTINATION/errfilename).
3. If no file separator is found in errfilename, the fatal error log is placed in the
JAVA_CORE_DESTINATION directory.
1.28 -XX:OnError
When a fatal error occurs, the Java VM can optionally execute a user-supplied script or command.
The script or command is specified using the -XX:OnError:<string> command-line option,
where <string> is a single command or a list of commands each separated by a semicolon.
Within <string> all occurrences of “%p” are replaced with the current process id (pid), and
all occurrences of “%%” are replaced by a single “%”.
The following example shows how the fatal error report can be mailed to a support alias when
a fatal error is encountered:
$ java -XX:OnError=cat hs_err_pid%p.log|mail support@acme.com MyApplication
The following example shows how to execute gdb when an unexpected error is encountered.
After gdb is started, it attaches to the Java VM process:
$ java -XX:OnError=gdb - %p MyApplication
1.29 -XX:+ShowMessageBoxOnError
In addition to the-XX:OnError option, the Java VM can also be provided with the
option-XX:+ShowMessageBoxOnError . When this option is set and a fatal error is encountered,
the Java VM outputs information about the fatal error and ask the user if the debugger should
be launched. The output and prompt are sent to the application console (standard input and
standard output). Following is an example:
==============================================================================
Unexpected Error ------------------------------------------------------------------------------
SIGSEGV (0xb) at pc=0x2000000001164db1, pid=10791, tid=1026
Do you want to debug the problem?
To debug, run 'gdb /proc/10791/exe 10791'; then switch to thread 1026
Enter 'yes' to launch gdb automatically (PATH must include gdb)
Otherwise, press RETURN to abort...
==============================================================================
In this case, a SIGSEGV has occurred and the user is prompted whether to launch the debugger
to attach to the process. If the user enters “y” or “yes” then gdb is launched.
In the previous example, the output includes the process id (10791) and also the thread id (1026).
If the debugger is launched then one of the initial steps taken in the debugger should be to select
the thread and obtain its stack trace.
While waiting for a response from the process, it is possible to use other tools to obtain a crash
dump or query the state of the process.
Generally, -XX:+ShowMessageBoxOnError option is more useful in a development
environment where debugger tools are available. The -XX:OnError option is more suitable for
production environments where a fixed sequence of commands or scripts are executed when a
fatal error is encountered.
50 Diagnostic and Monitoring Tools and Options