Skip to main content

Multi-Thread Run-time Analysis Tool for Java

A tool that detects and analyzes potential data race and deadlock conditions that might occur in multi-threaded Java programs.

Date Posted: March 11, 2008

alphaworks tab navigation


Update: March 3, 2009
New version is more stable due to bug fixes, and supports Linux/X86_64 and AIX/PPC64 platforms.

1. Is Multi-Thread Run-time Analysis Tool for Java™ for developers or for testers?

Both. The tool can be valuable to developers in checking the correctness of concurrent programs they write, as well as for testers in checking concurrency problems in software components or products.

2. How do I know what classes are instrumented and what classes are not instrumented?

In command line mode, set property -Dcom.ibm.mtrat.dbg.cl=true. In the Eclipse plug-in's front-end, go to Window > Preferences > Thread Analysis and select the check box Print debug message.

3. Why do the error reports vary from time to time?

The tool is a dynamic run-time checking tool. It will analyze the code that actually executed. If part of the code is not executed, the tool cannot analyze that part.

4. Why does a window pop up with the message "Could not locate the JAR files for instrumentation!" when I click on the red button in order to launch the application?

Before the tool launches applications for analysis, it will check for all necessary JAR files. If it cannot find all files, it will bring up this window. Please click on Window > Preferences... > Thread Analysis and select the correct directory in the box.

5. Why do I get the error "Please run this program at least one time before in this tool"?

When the tool launches programs, it will read the configuration of programs. Please run the program first, and then launch it by Multi-Thread Run-time Analysis Tool for Java in order to check data race and deadlock.

6. Does this tool work on Sun JDK?

Yes. Since Version 2.1 (mtrat-instrument-analysis-20081208), this tool works on both IBM® and Sun JDK platforms.

7. When I run mtrat.bat in Windows, why do I get this error?: Error opening zip file or JAR manifest missing : .\instrument.jar Error occurred during initialization of VM agent library failed to init: instrument.

This error occurs because users run mtrat.bat while the current working directory is not mtrat. For example, mtrat is located in C:\workspace\mtrat; user current working directory is C:\foo; and users will invoke mtrat.bat at the command line as follows:

C:\foo>c:\workspace\mtrat\mtrat.bat <main class>.

To fix the error, users must modify line 10 of mtrat.bat (set INSTALL_PATH =<mtrat install dir>), as in this example:

set INSTALL_PATH= C:\workspace\mtrat.

8. Can I run MTRAT for Tomcat?

Yes. MTRAT is composed of several jar files and a JVMTI agent library. Users can launch MTRAT in java command line with his/her applications. Suppose that tomcat is launched like:

 java <your option>org.apache.catalina.startup.Bootstrap start
and you download our package and have mtrat folder in
/home/sachin/mtrat
We could run MTRAT with tomcat like this:
/home/sachin/mtrat/mtrat -Xmx800m -x java.*:sun.*:javax.*-Dcom.ibm.mtrat.threadcache=true -Dcom.ibm.mtrat.osm=true org.apache.catalina.startup.Bootstrap start.
Or in Java command line:
java -Xmx800m -Xbootclasspath/p:/home/sachin/mtrat/target.jar:/home/sachin/mtrat/runtime.jar:/home/sachin/mtrat/asm-all-3.0.jar-javaagent:/home/sachin/mtrat/instrument.jar=exclude=java.*:sun.*:javax.* -agentpath:/home/sachin/mtrat/libjvmtiagent.so-Dcom.ibm.mtrat.threadcache=true -Dcom.ibm.mtrat.osm=true<your option> org.apache.catalina.startup.Bootstrap start.

9. Can I run MTRAT for Websphere Application Server?

  1. Download mtrat-instrument-analysis-.tar.gz package, and un-compress it.
  2. Generate target.jar per JVM shipped in WAS. Since target.jar varies on different JVM, take the following actions:
    1. Change your $JAVA_HOME, $CLASS_PATH, $PATH to JVM shipped in WAS
    2. Export JAVA_HOME=${WAS_HOME}/java
    3. Export CLASSPATH=$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$CLASSPATH
    4. export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH ./install.sh , or run java -cp asm-all-3.0.jar:class.jar com.ibm.threadanalysis.dynamic.tool.InstrumentClass.
  3. Create a new profile for WAS, say mtrat , Add java options in server.xml , Modify profiles/mtrat/config/cells/mtrat-testNode02Cell/nodes/mtrat-test/servers/server1/server.xml ,
The following options were added in server.xml:
-Xbootclasspath/p:/home/qiyao/workspace/com.ibm.threadanalysis.dynamic/mtrat/target.jar:/home/qiyao/workspace/com.ibm.threadanalysis.dynamic/mtrat/runtime.jar:/home/qiyao/workspace/com.ibm.threadanalysis.dynamic/mtrat/asm-all-3.0.jar 
-javaagent:/home/qiyao/workspace/com.ibm.threadanalysis.dynamic
/mtrat/instrument.jar=exclude=java.*:javax.*:sun.*:org.*:com
.ibm.ejs.ras.*:com.ibm.crypto.*:com.ibm.ws.security.*:com.ibm.
ws.crypto.*:com.ibm.security.*:com.ibm.websphere.security.*:
com.ibm.ISecurity*:com.ibm.jsse2.*:com.ibm.CORBA.*
:com.ibm.db2.*:com.ibm.websphere.samples.*:com.ibm.oti.*
:com.sun.*-agentpath:/home/qiyao/workspace/com.ibm.
threadanalysis.dynamic/mtrat/libjvmtiagent.so -Dcom.ibm.mtrat.
dbg.cl=true -Dcom.ibm.mtrat.threadcache=true 
-Dcom.ibm.mtrat.osm=true -Dcom.ibm.mtrat.race.oneobjectfield=true" disableJIT="false"/>

Trademarks




Related technologies