问题
Trying to execute .jmx (Jmeter) using maven project. Created jmx file in Jmeter 3.1 version. Using jmeter-maven-plugin 2.1.0. Getting following error while executing in command line using - mvn clean verify
[INFO] P E R F O R M A N C E T E S T S
[INFO] -------------------------------------------------------
[INFO] Invalid value detected for <postTestPauseInSeconds>. Setting pause to 0...
[INFO]
[INFO]
[INFO] Executing test: CCMTestPlan.jmx
[INFO] Writing log file to: E:\jmeter-mvn-master\jmeter-mvn- master\target\jmeter\logs\CCMTestPlan.jmx.log
[INFO] Error in NonGUIDriver java.lang.IllegalArgumentException: Problem loading XML from:'E:\jmeter-mvn-master\jmeter-mvn-master\target\jmeter\testFiles\CCMTestPlan.jmx', missing class com.thoughtworks.xstream.converters.ConversionException:
[INFO] ---- Debugging information ----
[INFO] cause-exception : com.thoughtworks.xstream.converters.ConversionException
[INFO] cause-message :
[INFO] first-jmeter-class : org.apache.jmeter.save.converters.HashTreeConverter.unmarshal(HashTreeConverter.java:67)
[INFO] class : org.apache.jmeter.save.ScriptWrapper
[INFO] required-type : org.apache.jorphan.collections.ListedHashTree
[INFO] converter-type : org.apache.jmeter.save.ScriptWrapperConverter
[INFO] path : /jmeterTestPlan/hashTree/hashTree/hashTree/hashTree[3]/com.atlantbh.jmeter.plugins.jsonutils.jsonpathextractor.JSONPathExtractor
[INFO] line number : 98
[INFO] version : 3.1 r1770033
[INFO] -------------------------------
Following is my pom.xml file
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>2.1.0</version>
<configuration>
<testResultsTimestamp>false</testResultsTimestamp>
<jmeterPlugins>
<plugin>
<groupId>kg.apc</groupId>
<artifactId>jmeter-plugins-extras-libs</artifactId>
</plugin>
</jmeterPlugins>
<testFilesIncluded>
<testFilesIncluded>CCMTestPlan.jmx</testFilesIncluded>
</testFilesIncluded>
<jmeterVersion>3.1</jmeterVersion>
</configuration>
<executions>
<execution>
<id>jmeter-tests</id>
<phase>verify</phase>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>kg.apc</groupId>
<artifactId>jmeter-plugins-extras-libs</artifactId>
<version>1.3.1</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
Does anybody faced this issue?
回答1:
Dependency configuration has changed in the 2.x versions of the plugin (see https://github.com/jmeter-maven-plugin/jmeter-maven-plugin/wiki/Adding-additional-libraries-to-the-classpath)
Adding jar's to the /lib/ext directory
You can add any additional Java libraries to JMeter's lib/ext directory by using the
<jmeterExtensions>
configuration element. This uses the Eclipse Aether libraries to perform dependency resolution.
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>2.1.0</version>
<executions>
<execution>
<id>jmeter-tests</id>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
<configuration>
<jmeterExtensions>
<artifact>kg.apc:jmeter-plugins:pom:1.3.1</artifact>
</jmeterExtensions>
</configuration>
</plugin>
</plugins>
</build>
[...]
</project>
+---+
When you define your dependencies properly you will probably see another error because jmeter-plugins depends upon JMeter 2.13 which has a broken maven dependency tree. This is something the jmeter-plugins team needs to fix (they need to release a version of jmeter plugins that depends upon JMeter 3.1).
The build will break because the plugin is trying to download some transitive dependencies for jmeter-plugins that don't exist, you can work around this by setting:
<downloadExtensionDependencies>false</downloadExtensionDependencies>
This does however mean that you will need to manually set all the dependencies that jmeter-plugins depends upon in your <jmeterExtensions>
block.
You can use mvn dependency:tree
to get the full list of dependencies required for the jmeter-plugins-extras-libs package.
The above information hasn't made it into the Wiki yet (there's an ongoing task to add this information and move everything across to the website), it is however available in the CHANGELOG:
https://github.com/jmeter-maven-plugin/jmeter-maven-plugin/blob/master/CHANGELOG.md
回答2:
use This it will work
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>jmeter</groupId>
<artifactId>qbo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>qbo</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>2.1.0</version>
<configuration>
<testResultsTimestamp>false</testResultsTimestamp>
</configuration>
<executions>
<execution>
<configuration>
<testFilesDirectory>src/test/jmeter/</testFilesDirectory>
</configuration>
<id>jmeter-tests</id>
<phase>verify</phase>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
来源:https://stackoverflow.com/questions/42467401/jmeter-error-in-nonguidriver-java-lang-illegalargumentexception