Tuesday May 13, 2008

Configuring JProfiler for GlassFish V2 Application Server

Ever wondered how you can configure JProfiler for GlassFish ? Here are 4 simple steps.....

1. Install and Configure GlassFish V2
  • Install and configure GlassFish V2 UR1 on all server instance machines.
  • If you are new to GlassFish, please take a QuickStart tour to understand basic concepts.
2. Download and Install JProfiler Version 4.3.2
  • Download JProfiler 4.
  • If you a have license for JProfiler, you can install the tool for licensed users. Otherwise, you can install the trial versions. JProfiler needs to be installed on all machines hosting instances that needs to be profiled.
  • Follow the installation notes in above link and start JProfiler.
  • Screen 1: Welcome to JProfiler Screen. 
    Click next.
  • Screen 2: Import Settings Screen.
    Select "No" and click next.
  • Screen 3: Enter License Key Screen.
    Select default Single or evaluation license and enter your name, company and license key.
  • Screen 4: Locate Java(TM) virtual machines Screen.
    Click stop search and add the jdk you are using for AppServer. Click next.
  • Screen 5: IDE Integration.
    Don't select anything and click next.
  • Screen 6: Configure web browser.
    Don't add anything and click next.
  • Screen 7: Setup is completed.
    Click finish.
  • Quick Start window pops up. Close this and close JProfiler window as well.
3. Configure JProfiler for Das instance
  • First we are going to try out JProfiler on domain instance to see if our setup is correct and get comfortable with the tool.
  • Save the domain.xml (<glassfish_install_dir>/domains/domain1/config/domain.xml) and asadmin scripts (<glassfish_install_dir>/bin/asadmin). Stop domain1 if it's running. When configuring JProfiler, it overwrites these 2 files. That's why we are saving the original copy just in case if we want to revert back to the original setup.
  • Bring up JProfiler. It will take you to Quick Start window. Close that window. You will have only one window opened which is the JProfiler window. 
  • Click Session tab -> select Integration Wizards -> select New Server Integration.
  • Screen 1: Integration Wizard.
    From drop down list, select GlassFish V2. Click next.
  • Screen 2: Where is the profiled application located ?
    Select "On this computer" and click next.
  • Screen 3: Locate the config file.
    Enter the location of domain.xml of domain1 and click next.
  • Screen 4: Locate the start script.
    Enter the location of asadmin script and click next.
  • Screen 5: Choose JVM vendor, version and mode.
    Select the same version used in AppServer.
  • Screen 6: Choose the port used for the profiling connection.
    Select default port which is 8849 and click next.
  • Screen 7: Choose whether to wait for the JProfiler GUI.
    Select "Don't wait, startup immediately".
  • Screen 8: Check required modifications.
    Check and click next
  • Screen 9: Integration is completed.
    Select "No, I will start the session later" and click finish
  • Go to AppServer bin directory. If asadmin_jprofiler is not in executable mode, then chmod 755 asadmin_jprofiler. Start domain1 using asadmin_jprofiler script. You will see JProfiler > prompts both on the command line and in server log. Domain1 will take some time to startup because of JProfiler settings but it should start successfully.
  • Once domain1 is started, open JProfiler, go to Session tab -> Click Open Session -> Highlight GlassFish V2 on localhost -> Click open -> It will take you to Profiling Settings -> Click ok.
  • You will then see all the objects displayed. The instance count and size should be increasing and decreasing. This shows JProfiler is attached to the domain and it is working fine.
  • You should try closing JProfiler window to see if the das is still working without any errors. This means that you can open JProfiler in the middle of the run to see what's happening and there is no need to keep JProfiler opened all the time for debugging. Running JProfiler during a run can slow down the server so it should only be used when it is necessary.
4. Configure JProfiler for Cluster Instances
  • Once JProfiler works on domain1, we can start configuring for cluster instances. The assumption made here is that Cluster, NodeAgents and Instances in a cluster are already created. On Das machine, set the start-servers-in-startup="false" for all the nodeagents. This way the node agents will not start the instances when it is started and you would have better control over the instances when configuring it with JProfiler.

    To set the start-servers-in-startup to false, issue the following asadmin command:

    <glassfish_install_dir>/bin/asadmin set --host <host_name> --port <admin_port> --user <admin_user_name> --passwordfile <admin_password_file> domain.node-agent.<agent_name>.start-servers-in-startup=false

  • Install JProfiler on all the instance machines following the above installation instructions (#2) and Das Configuration instructions (#3 until Screen 9). When providing the location of domain.xml for the instance, provide the domain.xml in the instance config directory.
    Example: /export/home/glassfish/nodeagents/agent1/instance1/config/domain.xml
  • JProfiler tool creates the following 4 lines under server-config in domain.xml of domain1.

    <profiler enabled="true" name="JProfiler">
              <jvm-options>-agentlib:jprofilerti=port=8849,nowait,id=107,config=/.jprofiler4/config.xml</jvm-options>
              <jvm-options>-Xbootclasspath/a:/export/home/jprofiler4/bin/agent.jar</jvm-options>
    </profiler>

    This needs to be created for your cluster-config as well. To create them, issue the following asadmin commands:

    <glassfish_install_dir>/bin/asadmin create-profiler --host <host_name> --port <admin_port> --user <admin_user_name> --passwordfile <admin_password_file> --target <cluster_name> JProfiler

    <glassfish_install_dir>/bin/asadmin create-jvm-options --host <host_name> --port <admin_port> --user <admin_user_name> --passwordfile <admin_password_file> --profiler=true --target <cluster_name> "-agentlib\\:jprofilerti\\=port\\=8849,nowait,id\\=101,config\\=/.jprofiler4/config.xml"

    <glassfish_install_dir>/bin/asadmin create-jvm-options --host <host_name> --port <admin_port> --user <admin_user_name> --passwordfile <admin_password_file> --profiler=true --target <cluster_name> "-Xbootclasspath/a\\:/export/home/jprofiler4/bin/agent.jar"

    The id 101 is used instead of 107 to avoid conflicts. Any id numbers can be used, as long as it doesn't conflict with id # 107. Stop and start domain1 with the asadmin_jprofiler script.
  • Start all the nodeagents using asadmin_jprofiler script with giving syncinstances=true option on command line so it syncs up it's domain.xml with das. From das machine, you can start the cluster using the modified asadmin_jprofiler script which will start all instances with JProfiler attached on id 101. You will see JProfiler > prompts both on the command line and in server log. The instances will take some time because of JProfiler settings but it should start successfully.
  • Once instances are started successfully, open JProfiler, go to Session tab -> Click Open Session -> Highlight GlassFish V2 on localhost -> Click open -> It will take you to Profiling Settings -> Click ok -> JProfiler is then connected to the instance.
  • You will then see all the objects displayed. The instance count and size should be increasing and decreasing. This shows JProfiler is attached to the instance and it is working fine.
  • You should try closing JProfiler window to see if the instance is still working without any errors. This means that you can open JProfiler in the middle of the run to see what's happening and there is no need to keep JProfiler opened all the time for debugging. Running JProfiler during a run can slow down the server so it should only be used when it is necessary.
  • Now, you are done with JProfiler Configuration and ready for Profiling GlassFish !!
5. Reference Links:
About

Meena Palani

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today