Debugging JMeter Plug-ins

When developing your own plugins, you’ll no doubt need to debug some sort of problem sooner or later. Writing log messages or even just printing directly to stdout will often give you the info you need, but eventually, you’ll want to hook up a debugger and step through your code. Fortunately, this is very easy and just needs the following lines added to the top of your start up scripts:

Linux/Mac – bin/jmeter.sh

JVM_ARGS="-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000"

Windows – bin/jmeter.bat

set JVM_ARGS=-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000

Now when you launch JMeter using either of these scripts, the JVM will start up with the debugger enabled and listening on port 8000. You can then use your IDE of choice to debug your plug-in. In my case, I’ve used Eclipse. To set up the debugger connection, select Debug Configurations… from the Run menu and you should see a dialog similar to the following:

The important things to note here is that you want to add a new Remote Java Application debug configuration and the project should be set to your plug-in project. Optionally, you might also want to add this configuration as a favourite to your debug menu which can be done on Common tab.

When you launch this configuration, the Eclipse debugger will establish a connection to your running JMeter instance and you will then be able to set break points and step through your code as normal. As an added bonus, if you’ve also downloaded the JMeter source code, you’ll be able to attach it to the JMeter Jars in your project allowing to step through the JMeter code as well without having to build it yourself. This is a great way to learn how JMeter works internally which may help you better understand any problems you see with you plug-ins.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: