JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
Oracle GlassFish Server 3.1 Application Development Guide
search filter icon
search icon

Document Information


Part I Development Tasks and Tools

1.  Setting Up a Development Environment

2.  Class Loaders

3.  Debugging Applications

Enabling Debugging

To Set the Server to Automatically Start Up in Debug Mode

JPDA Options

Generating a Stack Trace for Debugging

Application Client Debugging

GlassFish Server Message Queue Debugging

Enabling Verbose Mode

Class Loader Debugging

GlassFish Server Logging

Profiling Tools

The NetBeans Profiler

The HPROF Profiler

To Use HPROF Profiling on UNIX

The JProbe Profiler

To Enable Remote Profiling With JProbe

Part II Developing Applications and Application Components

4.  Securing Applications

5.  Developing Web Services

6.  Using the Java Persistence API

7.  Developing Web Applications

8.  Using Enterprise JavaBeans Technology

9.  Using Container-Managed Persistence

10.  Developing Java Clients

11.  Developing Connectors

12.  Developing Lifecycle Listeners

13.  Developing OSGi-enabled Java EE Applications

Part III Using Services and APIs

14.  Using the JDBC API for Database Access

15.  Using the Transaction Service

16.  Using the Java Naming and Directory Interface

17.  Using the Java Message Service

18.  Using the JavaMail API


Profiling Tools

You can use a profiler to perform remote profiling on the GlassFish Server to discover bottlenecks in server-side performance. This section describes how to configure profilers for use with GlassFish Server.

The following topics are addressed here:

Information about comprehensive monitoring and management support in the Java 2 Platform, Standard Edition (J2SE platform) is available at

The NetBeans Profiler

For information on how to use the NetBeans profiler, see

The HPROF Profiler

The Heap and CPU Profiling Agent (HPROF) is a simple profiler agent shipped with the Java 2 SDK. It is a dynamically linked library that interacts with the Java Virtual Machine Profiler Interface (JVMPI) and writes out profiling information either to a file or to a socket in ASCII or binary format.

HPROF can monitor CPU usage, heap allocation statistics, and contention profiles. In addition, it can also report complete heap dumps and states of all the monitors and threads in the Java virtual machine. For more details on the HPROF profiler, see the technical article at

After HPROF is enabled using the following instructions, its libraries are loaded into the server process.

To Use HPROF Profiling on UNIX

  1. Use the Administration Console. Select the JVM Settings component under the relevant configuration. Then select the Profiler tab.
  2. Edit the following fields:
    • Profiler Name – hprof

    • Profiler Enabled – true

    • Classpath – (leave blank)

    • Native Library Path – (leave blank)

    • JVM Option – Select Add, type the HPROF JVM option in the Value field, then check its box. The syntax of the HPROF JVM option is as follows:

      -Xrunhprof[:help]|[:param=value,param2=value2, ...]

      Here is an example of params you can use:


      The file parameter determines where the stack dump is written.

      Using help lists parameters that can be passed to HPROF. The output is as follows:

      Hprof usage: -Xrunhprof[:help]|[:<option>=<value>, ...]
      Option Name and Value   Description             Default
      ---------------------   -----------             -------
      heap=dump|sites|all     heap profiling          all
      cpu=samples|old         CPU usage               off
      format=a|b              ascii or binary output  a
      file=<file>             write data to file      java.hprof
                                     (.txt for ascii)
      net=<host>:<port>       send data over a socket write to file
      depth=<size>            stack trace depth       4
      cutoff=<value>          output cutoff point     0.0001
      lineno=y|n              line number in traces?  y
      thread=y|n              thread in traces?       n
      doe=y|n                 dump on exit?           y

      Note - Do not use help in the JVM Option field. This parameter prints text to the standard output and then exits.

      The help output refers to the parameters as options, but they are not the same thing as JVM options.

  3. Restart the GlassFish Server.

    This writes an HPROF stack dump to the file you specified using the file HPROF parameter.

The JProbe Profiler

Information about JProbe from Sitraka is available at

After JProbe is installed using the following instructions, its libraries are loaded into the server process.

To Enable Remote Profiling With JProbe

  1. Install JProbe

    For details, see the JProbe documentation.

  2. Configure GlassFish Server using the Administration Console:
    1. Select the JVM Settings component under the relevant configuration. Then select the Profiler tab.
    2. Edit the following fields before selecting Save and restarting the server:
      • Profiler Name – jprobe

      • Profiler Enabled – true

      • Classpath – (leave blank)

      • Native Library Path – JProbe-dir/profiler

      • JVM Option – For each of these options, select Add, type the option in the Value field, then check its box




      Note - If any of the configuration options are missing or incorrect, the profiler might experience problems that affect the performance of the GlassFish Server.

      When the server starts up with this configuration, you can attach the profiler.

  3. Set the following environment variable:

    See Step 6 for instructions on how to create the JPL file.

  4. Start the server instance.
  5. Launch the jpprofiler and attach to Remote Session. The default port is 4444.
  6. Create the JPL file using the JProbe Launch Pad. Here are the required settings:
    1. Select Server Side for the type of application.
    2. On the Program tab, provide the following details:
      • Target Server – other-server

      • Server home Directory – as-install

      • Server class File – com.sun.enterprise.server.J2EERunner

      • Working Directory – as-install

      • Classpath – as-install/lib/appserv-rt.jar

      • Source File Path – source-code-dir (in case you want to get the line level details)

      • Server class arguments – (optional)

      • Main Package – com.sun.enterprise.server

      You must also set VM, Attach, and Coverage tabs appropriately. For further details, see the JProbe documentation. After you have created the JPL file, use this an input to JPROBE_ARGS_0.