This tutorial explains how to profile Java code
with BEA WebLogic 6 or later.
In this document, <OptItDir>
is the directory where OptimizeIt has been installed. (ex: c:\OptimizeItDemo\OptimizeIt40D),
and <WebLogicDir> is the directory where WebLogic has been
installed (ex: c:\WebLogic6).
1) Configuring the startWebLogic6OI.bat script
-
Copy the file startWebLogic6OI.bat located
in the <OptItDir>\Tutorial\script to your domain root directory
(ex: <WebLogicDir>\config\mydomain).
-
Edit the new copied script
WebLogic properties
-
Enter <WebLogicDir> after the statement:
set WEBLOGIC_HOME=
-
Enter the name of your domain (ex: mydomain) after
the statement:
-
Enter the name of your server (ex: myserver) after
the statement:
set SERVER_NAME=
-
Change the path to the policy file if necessary after
the statement:
The value specified in the script .\lib\weblogic.policy
is the default value. Change this value only if your policy file is not
located under <WebLogicDir>\lib\weblogic.policy
-
(Optional) Enter the password of the server after
the statement:
Note that you do not have to specify the password
and can leave this property blank. In that case you will be prompted for
your server password each time you start WebLogic with this script.
Java properties
-
Enter the directory of the JDK 1.3 you want to use
with WebLogic (ex: c:\jdk1.3.0) after the statement:
-
If you wan to use the Hotspot runtime of the JDK 1.3, comment out the statement:
by adding rem at the beginning of the line.
Important note: the hotspot runtime of the JDK 1.3 cannot be
used for profiling because of some bugs in the profiling API. Make sure
to use the JDK 1.3.1 in order to profile with Hotspot.
-
(Optional) Add any needed extra paths to the classpath after the statement:
-
(Optional) Add any extra java parameters after the statement:
OptimizeIt properties
-
Enter <OptItDir> after the statement:
-
(Optional) Comment out the line:
set OPTIT_MAIN_CLASS=intuitive.audit.Audit
by adding rem at the beginning of the line, if you want to
use the OptimizeIt servlet. Using the OptimizeIt servlet improves the startup
performances of the server. See the chapter 6 'Using
the OptimizeIt servlet' for more information.
-
(Optional) Change the port number used by the audit system if necessary
by modifying the line:
The size is in Mb. The default value is 2 Mb.
2) Configuring the weblogic.policy file
In order to profile, you need to give OptimizeIt's
classes the correct rights:
-
Edit the policy file of your server. This file is
the file you specified after the WEBLOGIC_POLICY statement in the previous
section. The default location for that file is <WebLogicDir>\lib\weblogic.policy
-
Add the following lines at the end of the file:
3) Starting WebLogic
To start WebLogic, invoke the startWebLogic6OI.bat
script:
4) Attaching from OptimizeIt
Now that WebLogic is running with OptimizeIt profiler, you can start OptimizeIt
and attach to the virtual machine.
-
Start OptimizeIt from the Start menu.
-
Close the Edit Settings panel by pressing the OK button.
-
From the Program menu, select Attach.
-
Change the port number and the hostname if necessary.
-
Press the Attach button.
Note: OptimizeIt does not have a "detach" function. If you press
the stop button in OptimizeIt, WebLogic server exits. After doing this,
you need to restart WebLogic server.
5) Filtering resources used by WebLogic
OptimizeIt provides filters for filtering resources used by WebLogic. In
order to use filters, you must create an OptimizeIt setting for the profiling
session, turn on the WebLogic filter, and then attach by using the
Attach now button or pressing the play button.
-
Start WebLogic using the startWebLogic6OI.bat
script.
-
Start OptimizeIt from the Start menu.
-
Close the settings editor by pressing OK.
-
From the File menu, select New
-
In the Edit Settings panel select Remote
Application in the Program type part.
-
Change the hostname or the port number if necessary.
-
Switch to the Filters section by clicking the
Filters
tab.
-
In the table, find the line with the name BEA
WebLogic.
-
If you want to ignore CPU or time consumed by
WebLogic, check the Ignore CPU usage column on that line.
-
If you want to ignore object allocations performed
by WebLogic, check the Ignore Memory usage column on that line.
-
Press the Attach now button.
Note: OptimizeIt settings can be saved for subsequent usage. This
is done by using the save menu.
6) Using the OptimizeIt
servlet
The startWebLogic6OI.bat script starts by default WebLogic with the OptimizeIt
audit system. The audit system retrieves the profiling information from
the start-up of WebLogic.
In order to improve the sever start-up performances, you can use the
OptimizeIt servlet to start the audit system once the server has started.
Modifying the startWebLogic6OI.bat script
-
Edit the startWebLogic6OI.bat script
-
Comment out the line
set OPTIT_MAIN_CLASS=intuitive.audit.Audit
by adding rem at the beginning of the line, the line becomes:
rem set OPTIT_MAIN_CLASS=intuitive.audit.Audit
Adding the OptimizeIt servlet to the WebLogic server
-
Copy the OptimizeIt servlet class located under <OptItDir>\lib\servlet\OptimizeIt.class
to your server classes directory. For example with the domain mydomain
and a server myserver, we would copy the servlet class to: <WebLogicDir>\config\mydomain\applications\DefaultWebApp_myserver\Web-inf\classes
-
Edit the web.xml file of the server, located under the Web-inf
directory (in our previous example, the full path to this file would be
<WebLogicDir>\config\mydomain\applications\DefaultWebApp_myserver\Web-inf\web.xml).
-
Append the following lines in between the <web-app> ... </web-app>
tags:
<servlet>
<servlet-name>
OptimizeIt
</servlet-name>
<servlet-class>
OptimizeIt
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>
OptimizeIt
</servlet-name>
<url-pattern>
OptimizeIt
</url-pattern>
</servlet-mapping>
Accessing the OptimizeIt servlet
-
Start the WebLogic server with the startWebLogic6OI.bat script
-
Access the OptimizeIt servlet with the URL http://localhost:8080/OptimizeIt
where you should replace 8080 by the port the web server is using.
-
In the HTML page that the servlet provides, change the port number if necessary.
-
Select the "Disable memory profiler" option if you only want to focus on
CPU usage.
-
Select "Enable OptimizeIt's audit system API" if your code enables/disables
the profiler by using OptimizeIt's audit system API
-
Press the "Start OptimizeIt Audit System" button to start the profiler.
Once this operation is done, you should see a message in your web browser
indicating that OptimizeIt's audit system is running. At that point you
can attach from the OptimizeIt GUI as explained in the section 4 'Attaching
from OptimizeIt'.
Copyright (c) 1997, 1998, 1999, 2000, 2001 Intuitive
Systems Inc. All rights reserved. Specifications subject to change without
notice.
OptimizeIt is a trademark of Intuitive Systems, Inc.
Java and all Java-based trademarks and logos are trademarks
or registered trademarks of Sun Microsystems, Inc. All other brand names
and products are trademarks or registered trademarks of their respective
holders.