【问题标题】:Maven jmeter plugin: SAXParseException: Content is not allowed in prologMaven jmeter插件:SAXParseException:prolog中不允许内容
【发布时间】:2015-04-20 04:27:58
【问题描述】:

我的 jmeter 的 jmx 文件中有类似的内容:

<stringProp name="SoapSampler.URL_DATA">http://192.168.0.1:8080/abc/Service</stringProp>

我在进行 maven 构建时使用 jmeter maven 插件来获取性能测试结果。它运行良好。

现在我将其更改为 jmeter 中的用户定义变量并尝试运行它。我收到以下错误:

“SAXParseException:prolog 中不允许内容”

jmx 文件的变化:

      <elementProp name="server" elementType="Argument">
        <stringProp name="Argument.name">server</stringProp>
        <stringProp name="Argument.value">http://192.168.0.1:8080</stringProp>
        <stringProp name="Argument.metadata">=</stringProp>
      </elementProp>


<stringProp name="SoapSampler.URL_DATA">${server}/abc/Service</stringProp>

但是,如果直接从 jmeter GUI 执行修改后的更改,则可以完美运行。仅在 maven 构建期间执行时失败。

这是我的 pom.xml:

<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>com.abc.def.performance</groupId>
<artifactId>abc-performance</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>



<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>



<build>
    <plugins>
        <plugin>
            <groupId>com.lazerycode.jmeter</groupId>
            <artifactId>jmeter-maven-plugin</artifactId>
            <version>1.9.0</version>
            <executions>
                <execution>
                    <id>jmeter-tests</id>
                    <phase>verify</phase>
                    <goals>
                        <goal>jmeter</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
            </configuration>
        </plugin>
        <plugin>
            <groupId>com.lazerycode.jmeter</groupId>
            <artifactId>jmeter-analysis-maven-plugin</artifactId>
            <executions>
                <execution>
                    <phase>verify</phase>
                    <goals>
                        <goal>analyze</goal>
                    </goals>
                    <configuration>
                        <!-- An AntPath-Style pattern matching a JMeter XML result file to 
                            analyze. Must be a fully qualified path. File may be GZiped, must end in 
                            .gz then. Default: not set. Required. -->
                        <source>${project.build.directory}/**/*.jtl</source>
                        <!-- directory where to store analysis result files. Default: ${project.build.directory} 
                            Required. -->
                        <targetDirectory>${project.build.directory}/results</targetDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

【问题讨论】:

  • 你能发布你的 pom.xml
  • 你能否创建一个空文件,复制你的 pom 内容并使用 UTF-8 编码再次保存,然后再次尝试运行它。
  • @Balaji 这没有意义。我们不会更改 pom 文件。当我们修改 jmx 文件以使用用户定义的变量时会出现此错误。
  • 但是你确实提到当你正常运行 jmeter 时它工作正常,只有当你通过 pom 运行时它才会失败。看起来你的 pom 有“bom - 字节顺序标记”。这就是为什么要求您执行上述操作。 rgagnon.com/javadetails/java-handle-utf8-file-with-bom.html
  • 对于没有用户定义变量的初始情况,相同的 pom 工作。只有当我们在 jmx 中添加用户定义的变量时才会出现问题。

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


【解决方案1】:

确保jmeter.save.saveservice.output_format=xml 和 从您的 jmeter.properties 文件中取消注释以下行(在 jmeter 安装文件夹的 bin 文件夹内):

jmeter.save.saveservice.output_format=xml
jmeter.save.saveservice.data_type=true
jmeter.save.saveservice.label=true
jmeter.save.saveservice.response_code=true
jmeter.save.saveservice.successful=true
jmeter.save.saveservice.thread_name=true

【讨论】:

    【解决方案2】:

    当结果文件不是 xml 格式时,xml 解析器会触发此特定错误消息。结果文件可能是 CSV 格式,因为 output_format 未设置为 XML

    【讨论】:

      猜你喜欢
      • 2011-07-05
      • 2018-06-09
      • 1970-01-01
      • 2018-12-03
      • 2011-06-01
      • 2011-07-23
      相关资源
      最近更新 更多