Put the jar in jmeter/lib folder.
lib/ext is for real plugins.
Pergunta
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.
Solução 2
Put the jar in jmeter/lib folder.
lib/ext is for real plugins.
Outras dicas
As per How do I run JMeter in non-gui mode article you can use -J
key to provide additional classpath elements location to JMeter like below:
./jmeter -Juser.classpath=/some/folder/your/extension.jar -n -t ${path_to_your_script} -l ${path_to_results}
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>2.7.0</version>
<executions>
<execution>
<id>jmeter-tests</id>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
<configuration>
<testPlanLibraries>
<artifact>org.apache.commons:commons-lang3:3.0</artifact>
</testPlanLibraries>
<propertiesSystem>
<user>${username}</user>
</propertiesSystem>
</configuration>
</plugin>
I had the same issue today with jmeter 5.4 on a linux machine. Thanks to my colleague we identified the root cause.
In jmeter.properties we use the following line to extend the classpath libs. user.classpath=../lib;../lib/ext
Howerver on a linux machine this line hast to be look like: user.classpath=../lib:../lib/ext
Thus use : instead of ; In our case this fits our problem.
Add it as a dependency inside the jmeter plugin:
<dependencies>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.0-801.jdbc4</version>
</dependency>