question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

plugin incorrectly filters out project's jar and test-jar

See original GitHub issue

Problem:

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:open
  • Created 2 years ago
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Ardescocommented, Jan 16, 2022

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 to pre-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]):

<plugin>
    <groupId>com.lazerycode.jmeter</groupId>
    <artifactId>jmeter-maven-plugin</artifactId>
    <version>3.5.0</version>
    <executions>
        <!-- Generate JMeter configuration -->
        <execution>
            <id>configuration</id>
            <goals>
                <goal>pre-integration-test</goal>
            </goals>
        </execution>
        <!-- Run JMeter tests -->
        <execution>
            <id>jmeter-tests</id>
            <goals>
                <goal>jmeter</goal>
            </goals>
        </execution>
        <!-- Fail build on errors in test -->
        <execution>
            <id>jmeter-check-results</id>
            <goals>
                <goal>results</goal>
            </goals>
        </execution>
    </executions>
</plugin>
0reactions
shawnmckinneycommented, Jan 17, 2022

Agreed. Another point of confusion is how to include the test jars. This is what worked for me:

<artifact>org.apache.directory.fortress:fortress-core:jar:tests:${project.version}</artifact>

I’m willing to help if need be.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to resolve Unknown artifact type[test-jar] error in Maven?
solution: in windows, open cmd, cd root directory of your the project first, then type mvn dependency:tree in the cmd, to find transitive...
Read more >
[#MWAR-433] Maven WAR plugin is deleting files generated ...
My project generates wsdls using the jaxws-maven-plugin which puts the ... Then I have a client jar that copies those wsdls out of...
Read more >
Testing in Java & JVM projects - Gradle User Manual
A test task of type Test that runs those unit tests. The JVM language plugins use the source set to configure the task...
Read more >
Many "cannot find symbol" errors building with Maven & Eclipse
Can i get any suggestion to fix the problem? ... [INFO] [INFO] —- maven-jar-plugin:2.3.2:jar (default-jar) @ openmrs-tools —- [INFO] Building jar: ...
Read more >
Unable to build the Confluence plugin jar 100% using atlas ...
atlassian-plugin-sdk-8.0.16 version used for build the plugin. ... and Let us know how to fix the problem and build the apps with 100%....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found