Search code examples
javaclasspathjmeterbenchmarking

How to add jars to JMeter's classpath in non-GUI mode


I have created a test plan in the JMeter GUI which uses the "Java Request Sampler".

I added the jarfile which contains the implementation to my sampler to /lib/ext/ of my jmeter installation.

This all works fine when I run it in GUI mode.

However when I switch to non gui mode using

./jmeter -n -t Test\ Plan.jmx 

I get:

com.mycompany.JavaSamplerTest java.lang.ClassNotFoundException

2014/01/23 15:25:25 ERROR - jmeter.protocol.java.sampler.JavaSampler: StandardJMeterEngine@5efbfd6e-Java Request    Exception initialising: com.mycompany.JavaSamplerTest java.lang.ClassNotFoundException: com.mycompany.JavaSamplerTest
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:270)
at org.apache.jmeter.protocol.java.sampler.JavaSampler.initClass(JavaSampler.java:117)
at org.apache.jmeter.protocol.java.sampler.JavaSampler.testStarted(JavaSampler.java:263)
at org.apache.jmeter.engine.StandardJMeterEngine.notifyTestListenersOfStart(StandardJMeterEngine.java:214)
at org.apache.jmeter.engine.StandardJMeterEngine.run(StandardJMeterEngine.java:336)
at java.lang.Thread.run(Thread.java:744)

I have no clue why this behaves differently when using -n -t. Does anybody have a solution to this?

I work on Linux using openjdk if this is somehow a helpful information.


Solution

  • Put the jar in jmeter/lib folder.

    lib/ext is for real plugins.