JMeter + Eclipse HOWTO

Mar 10 2004

Michal Kostrzewa (m.kostrzewa@pentacomp.com.pl)

Special thanks to (text taken from)

Revision history

Abstract

This document describes briefly how to develop the JMeter project with Eclipse IDE. Eclipse is a very powerful development environment with following features: Eclipse is available for download for different platforms at http://www.eclipse.org

Multiple Workspaces

Most Eclipse formatting settings are managed at the workspace level. If you work on other projects in addition to JMeter, you probably don't want the JMeter formatting to apply to your other projects. One way to manage this is to set up multiple Eclipse workspaces -- one for JMeter, and one (or more) for other projects. To use multiple workspaces, simply start eclipse with the "-data" parameter:

    eclipse -data c:\workspace_JMeter
You could also create a batch file, shell script, or Windows shortcut to automatically specify the workspace so you don't have to type it each time.

Setting up JMeter + Eclipse

I assume you downloaded Eclipse IDE and have it working.

Accessing CVS

  1. Open the CVS perspective with perspective and cvs buttons
  2. Invoke the popup menu and select "New"|"repository location"
  3. Fill appropriate entries as pictured below, entering anoncvs as a password.:
    newcvs
  4. You should see the apache cvs tree as pictured below. Unfold HEAD, select jakarta-JMeter and then select "Check Out as ..." from the pop-up menu
    cvstree
  5. Select "JAVA project", and give a name for the project in next dialogs. I will assume I it is is named jmeter-pserver for the rest of this document.
  6. Wait for the cvs checkout to complete

Setting up paths

After the checkout you'll see something like this:
after cvs checkout
It means you have the source paths improperly installed. To set them up, do the following:
  1. Close this project
  2. Copy the jmeter-pserver/eclipse.classpath file to jmeter-pserver/.classpath (you will have to overwrite the jmeter-pserver/.classpath file eclipse created for you
  3. Open the project again
  4. Now the source folders and jar libraries are mounted properly
NOTE: There are some optional libraries JMeter depends on. This setup defines exclusion filters for all the classes that need optional libraries (you would get compiler errors from Eclipse otherwise). Remove these exclusion filters if you have optional libraries installed. For further details refer to jmeter-pserver/eclipse.readme)

Running JMeter with Eclipse and Ant

  1. Select Window|Show View|Ant. On the view like depicted below click the "Add Buildfile" button
  2. Select the build.xml file
    buildfile
  3. Run the ant target package (running "all" target would result with a clean compile, which would erase classes compiled by Eclipse itself).
    NOTE: The "package" target checks if there is something to compile before packaging. When working with Eclipse and having the "Window|Preferences|Workbench|Perform build automatically on resource modification" option turned on, the IDE compiles almost everything when saving the source, so checking if there is something left to compile is not neccessary. You can consider using the package-only target, that does not compile anything. This will shorten the compilation time
  4. After compiling JMeter you can make it run in a usual way (starting the jmeter-pserver/bin/jmeter script). But - behold! - there is a possibility to run and debug it under Eclipse.
  5. Running and debugging from Eclipse

    1. Find the NewDriver class on "Java browser perspective"
      newdriver
    2. Select "Run"|"Run ..." from the menu
    3. Select "Java application" from the side tree and click "New". JMeter running configuration will be added
    4. Select the "Arguments" tab, uncheck "Use default working directory" and correct the working directory field to jmeter-pserver/bin
    5. Select the "Classpath" tab, uncheck the "Default class path" checkbox, remove the "jmeter-pserver" entry (it should be the first one), click "Add JARs" and add bin/ApacheJMeter.jar. The final setup should look like this:
      classpath
    6. Configure the source for debug: choose the "Source" tab, uncheck the "Default source lookup path" checkbox, click "Add Projects...", check the jmeter project. Thie final setup should look like this:
      sourcepath
    7. Click "Run"
    8. From this time on you can run and debug JMeter simply by pressing run and debug buttons

Running and debugging JMeter without Ant

It is very simple to use Ant while using Eclipse; you can even run and debug a code built in such a way. However, this method has one drawback. It can be tiresome always to run this package-only target; it also takes some time. You can configure your environment to run JMeter directly, without all that repackaging. Do the following:
  1. In the "Project properties" window exclude *.resources and images from src/core exclusion filter. The exclusion filter should look like this:
    exclusion
  2. Make sure the directory jmeter-pserver/lib/ext is empty. If not - run ant clean and then rebuild the project with Eclipse
  3. Add the following one line to your jmeter-pserver/bin/jmeter.properties file:
            search_paths=build/protocol/ftp;build/protocol/http;build/protocol/java;build/protocol/jdbc;build/protocol/ldap;build/protocol/tcp;build/components;build/core;build/default;build/functions;build/htmlparser;build/jorphan
    	
  4. Find the NewDriver class on "Java browser perspective"
    newdriver
  5. Select "Run"|"Run ..." from the menu
  6. Select "Java application" from the side tree and click "New". JMeter running configuration will be added
  7. Important: Select the "Arguments" tab, uncheck "Use default working directory" and correct the working directory field to jmeter-pserver/bin
  8. Select the "Classpath" tab, make sure the "Use default class path" option is checked
  9. Select the "Source" tab, make sure the "Use default source lookup path" option is checked
  10. Click "Run"
  11. From this time on you can run and debug JMeter simply by pressing run and debug buttons

Formatting files

In order to match the conventions agreed to by JMeter committers in January 2003 (see [the mailing list archive]) the following settings are recommended. These settings are present in Eclipse 2.1.1 -- earlier or later versions probably have similar settings, but possibly in different places.

NOTE: ASF officials strongly discourage using of an @author tag, because of licencing issues (ASF Board Summary for February 18, 2004).

Comments

Please send your comments concerning eclipse+JMeter as well as grammar/spelling issues either to JMeter mailing list or to me (m.kostrzewa@pentacomp.com.pl).