plugin incorrectly filters out project's jar and test-jar
See original GitHub issueProblem:
Jmeter plugin will filter out testPlan libraries when setting both the project’s main and test jars. For example:
<testPlanLibraries>
<artifact>org.apache.directory.fortress:fortress-core:jar:tests:${project.version}</artifact>
<artifact>org.apache.directory.fortress:fortress-core:${project.version}</artifact>
...
</testPlanLibraries>
When I run a test, will get:
2022-01-14 15:54:31,095 ERROR o.a.j.JMeter: Uncaught exception in thread Thread[StandardJMeterEngine,5,main]
java.lang.NoClassDefFoundError: org/apache/directory/fortress/core/SecurityException
Note, that class is contained within the fortress-core artifact. So when I view the contents of
$ ls target/9998d2e4-c17b-4992-b3c5-c925e4651ae9/jmeter/lib/fortress-core*
target/9998d2e4-c17b-4992-b3c5-c925e4651ae9/jmeter/lib/fortress-core-2.0.8-SNAPSHOT-tests.jar
Older version of the plugin didn’t have this problem:
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>1.10.1</version>
...
<dependencies>
<dependency>
<groupId>org.apache.directory.fortress</groupId>
<artifactId>fortress-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.directory.fortress</groupId>
<artifactId>fortress-core</artifactId>
<type>test-jar</type>
<version>${project.version}</version>
</dependency>
$ ls target/jmeter/lib/fortress-core*
target/jmeter/lib/fortress-core-2.0.8-SNAPSHOT.jar target/jmeter/lib/fortress-core-2.0.8-SNAPSHOT-tests.jar
The older version is the correct behavior. There is no workaround for this problem that I know of. It prevents projects from pulling from both the main and tests jars for running jmeter.
I also described this problem on the ML but have not yet received a response: https://groups.google.com/g/maven-jmeter-plugin-users/c/HhH7T1Q34M8
I’m happy to help test and document a fix, as needed, but don’t have any experience developing maven plugins. Would be willing to take this on if someone from the project would mentor.
Thanks
– Shawn
Issue Analytics
- State:
- Created 2 years ago
- Comments:14 (6 by maintainers)
Top GitHub Comments
The older version of the plugin (1.x.x) didn’t use mavens phases correctly. This was changed with the version 2.0.0 release of the plugin.
In that old version it would do everything in the integration-test phase (Download jars, configure JMeter and then run tests). This meant that if you were trying to run multiple different tests it would clobber your output, and if you were trying to run different tests with different JMeter configurations in parallel the second test would reconfigure JMeter in the same directory while the first test was running (causing various issues). It also means that rerunning a test would always download and reconfigure JMeter (which isn’t really needed).
The plugin now configures the various JMeter setups that you have specified in the compile phase, stores a link to that configuration in the config.json in your target directory and then runs the tests in the integration-test phase.
You may be able to work around the issue by doing the following (note the change in the configuration execution ID, it has been moved from
configure
topre-integration-test
, the configure name is mapped to the compile phase - (https://github.com/jmeter-maven-plugin/jmeter-maven-plugin/blob/main/src/main/java/com/lazerycode/jmeter/mojo/ConfigureJMeterMojo.java#L49)[https://github.com/jmeter-maven-plugin/jmeter-maven-plugin/blob/main/src/main/java/com/lazerycode/jmeter/mojo/ConfigureJMeterMojo.java#L49]):Agreed. Another point of confusion is how to include the test jars. This is what worked for me:
I’m willing to help if need be.