Integrating NetBeans IDE Profiler With Sun Java System Web Server 7.0

By Yamini K. Balasubramanyam, April 9, 2007  

Even though profiling simple applications is usually a straightforward task, setting up a profiler to work on a Web server or application server requires extra steps. Configuring the Profiler in the NetBeans IDE (henceforth, NetBeans Profiler), however, is easily accomplished, usually on the first attempt. Not only does NetBeans Profiler support a wide range of profiling tasks on the Solaris, Windows, and Linux (Ubuntu) platforms, it also delivers numerous benefits. Among the benefits are—

  • Dynamic bytecode instrumentation, which extracts and injects bytecode at runtime with the Java virtual machine to generate events on method entry, exit, and so on. With the event data, NetBeans Profiler then collects and displays the related performance statistics. That means you can manage profiling tasks at runtime without restarting your application. For example, you can collect the CPU performance data, reset the results, and then enable thread monitoring to view a host of useful statistics, including those on memory use and thread management.
  • Robust support of performance tracking tasks, such as those performed with the CPU performance analyzer, the memory analyzer, and the thread profiler. NetBeans Profiler also contains a code fragment analyzer that measures the execution time of selected code segments, so you need not include System.currentTimeMillis() in your code any more.
  • Tight integration with the NetBeans IDE, which boasts a code browser, a debugger—all within the same environment.
  • Minimal overhead, along with efficient performance.
  • Support for local and remote profiling, which spells flexibility and convenience.
Overview of the GUI
Downloads and Initial Setup
Integration Steps
Overview of the GUI

This section highlights the related GUI.

Figure 1 shows the NetBeans Profiler console.

Figure 1: NetBeans Profiler Console

Here, you can perform many profiling tasks, among them the following:

  • Start, stop, or reset the results buffer.
  • Switch profiling tasks.
  • View the virtual-machine telemetry.
  • View the live results or take snapshots of the data; also open, delete, export, or load snapshots.

Figure 2 shows the wizard for profiling tasks in the NetBeans IDE.

Figure 2: Wizard for Profiling Tasks in NetBeans IDE

Figure 3 shows a display of CPU performance measurements.

Figure 3: CPU Performance Measurements

Figure 4 shows a display of threads.

Figure 4: Threads
Downloads and Initial Setup

Before embarking on profiling tasks, first download the following:

Next, do the following:

  1. Start the NetBeans IDE.

    Note the Profile tab at the top.
  2. Run a one-time calibration on the target virtual machine: From the Profile menu at the top, choose Advanced Commands > Run Profiler Calibration.
Integration Steps

This section describes how to integrate NetBeans Profiler into Web Server 7.0.

Configuring Your Web Server Instance
First, configure your Web Server instance to load the NetBeans agent library from the administration command-line interface (CLI), wadm. For details on wadm, see the Sun Java System Web Server 7.0 CLI Reference Manual .

Note: Type all the commands on one line even though some of them wrap to the next line because of page width constraints.

  1. Ensure that the Administration Server is running and connect to it. Here is the command line and example output:

    $ wadm -u admin -w /space/admin.pwd
    Sun Java System Web Server 7.0U1-Technology-Preview-1 B03/13/2007 11:03
  2. Create a Java-virtual-machine profiler for the Web Server instance you would like to profile:

    wadm> create-jvm-profiler --config=test NetBeans
    CLI201 Command 'create-jvm-profiler' ran successfully
    wadm> list-jvm-profilers --config=test --all --verbose
    name enabled
    NetBeans true
  3. Add the options to load the agent library when you start the Web Server instance:

    wadm> create-jvm-options --config=test --profiler=NetBeans -- -agentpath:/space/netbeans-5.5/
    CLI201 Command 'create-jvm-options' ran successfully
    wadm> list-jvm-options --config=test --profiler=NetBeans
  4. Deploy the configuration to the instance:

    wadm>deploy-config test
    CLI201 Command 'deploy-config' ran successfully

Attaching NetBeans Profiler
Finally, attach the NetBeans Profiler:

  1. From the Profile menu in the NetBeans IDE, choose Attach Profiler to display the NetBeans Profiler wizard (see Figure 2). Click the Attach Wizard button.
  2. Choose J2EE Web/App Server from the Target Type drop-down menu and Generic Web/App Server from the Server Type drop-down menu. Click Next.
  3. Select Local or Remote under "Select Server location."

    If you select Remote, NetBeans Profiler prompts you in the bottom half of the screen to specify the configuration for the remote system. Type the remote host name in the Hostname field and specify the host OS by choosing from its drop-down menu.
  4. Select Direct under "Select attach method." Click Next.

    The NetBeans IDE displays the attach settings and prompts you to review them. Afterward, the Choose Integration Type screen is displayed.
  5. Select Manual. Click Next.

    The Choose Target JVM screen is displayed.
  6. Select "Java5.0_04 and newer" as the Java platform that will run your server. Click Next.

    The Review Integration Steps screen is displayed. You'll have already performed the steps on the screen in step 3 of the preceding subsection.
  7. Start the Web Server instance.

    Here is an example of the subsequent log messages displayed in the instance:

    [15/Mar/2007:11:00:35] info ( 7092): CORE1116: Sun Java System Web Server 7.0U1-Technology-
    Preview-1 B03/13/2007 11:03
    [15/Mar/2007:11:00:35] warning ( 7093): CORE3283: stderr: Profiler Agent: Initializing ...
    [15/Mar/2007:11:00:35] warning ( 7093): CORE3283: stderr: Profiler Agent: Options: >/space/
    [15/Mar/2007:11:00:35] warning ( 7093): CORE3283: stderr: Profiler Agent: Initialized
    [15/Mar/2007:11:00:35] info ( 7093): CORE3282: stdout: Profiler Agent: Waiting for connection
    on port 5140 (Protocol version: 2)
  8. Select the profiling task and click Attach.

    The Web Server instance continues to run.

Here is the sample output of a local profiling task:

[15/Mar/2007:11:02:06] info ( 7093): CORE3282: stdout: Profiler Agent: Established local
connection with the tool
[15/Mar/2007:11:02:09] info ( 7093): CORE5076: Using [Java HotSpot(TM) Server VM, Version
1.5.0_09] from [Sun Microsystems Inc.]
[15/Mar/2007:11:02:19] info ( 7093): WEB0100: Loading web module in virtual server [test] at [/
[15/Mar/2007:11:02:34] info ( 7093): HTTP3072: http-listener-1: http://kosmo:1894 ready to
accept requests
[15/Mar/2007:11:02:35] info ( 7093): CORE3274: successful server startup

Managing Instances With NetBeans Plug-in
If you have installed the NetBeans plugin for Web Server 7.0, you can manage Web Server instances within the IDE. As shown in Figure 5, a screenshot of the window for monitoring threads, the NetBeans IDE lists Web Server 7.0 under Servers on the left pane. The bottom pane displays the log of handshake messages between the NetBeans Profiler and the Web server instance.

Figure 5: Monitoring of Threads

To start the instance from within the IDE:

  1. From the Window menu at the top, choose Runtime > SJSWS 7.0.
  2. Right-click the configuration name and choose Start Instance from the context menu.

Figure 6 shows the Runtime window.

Figure 6: Runtime Window

Viewing Garbage Collection Statistics With Visual GC Plug-in
If you have installed the Visual GC plug-in in the NetBeans IDE, you can view the statistics on garbage collection there. Figure 7 shows an example.

Figure 7: Garbage Collection Statistics
Rate and Review
Tell us what you think of the content of this page.
Excellent   Good   Fair   Poor  
Your email address (no reply is possible without an address):
Sun Privacy Policy

Note: We are not able to respond to all submitted comments.
Left Curve
Java SDKs and Tools
Right Curve
Left Curve
Java Resources
Right Curve
Java 8 banner (182)