Jmeter- NonGUIDriver中的错误java.lang.IllegalArgumentException

时间:2017-02-26 10:36:15

标签: maven jmeter jmeter-plugins jmeter-maven-plugin

尝试使用maven项目执行.jmx(Jmeter)。 在Jmeter 3.1版本中创建了jmx文件。 使用jmeter-maven-plugin 2.1.0。 使用--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] -------------------------------

以下是我的pom.xml文件

<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>

有人遇到过这个问题吗?

2 个答案:

答案 0 :(得分:2)

插件的2.x版本中的依赖关系配置发生了变化(请参阅https://github.com/jmeter-maven-plugin/jmeter-maven-plugin/wiki/Adding-additional-libraries-to-the-classpath

  

将jar添加到/ lib / ext目录

     

您可以将任何其他Java库添加到JMeter的lib / ext   目录使用<jmeterExtensions>配置元素。   这使用Eclipse Aether库来执行依赖   分辨率。

<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>
+---+

当您正确定义依赖关系时,您可能会看到另一个错误,因为jmeter-plugins依赖于具有损坏的maven依赖关系树的JMeter 2.13。这是jmeter-plugins团队需要修复的东西(他们需要发布一个依赖于JMeter 3.1的jmeter插件版本)。

构建将中断,因为插件正在尝试下载不存在的jmeter-plugins的一些传递依赖项,您可以通过设置来解决此问题:

<downloadExtensionDependencies>false</downloadExtensionDependencies>

但这意味着您需要在<jmeterExtensions>块中手动设置jmeter-plugins所依赖的所有依赖项。

您可以使用mvn dependency:tree获取jmeter-plugins-extras-libs包所需的完整依赖项列表。

以上信息尚未进入Wiki(这是一项持续的任务,即添加此信息并将所有内容移至网站上),但是在CHANGELOG中可以使用:

https://github.com/jmeter-maven-plugin/jmeter-maven-plugin/blob/master/CHANGELOG.md

答案 1 :(得分:0)

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>