【问题标题】:Error converters.ConversionException when I run jmeter by java code当我通过 java 代码运行 jmeter 时出现错误 converters.ConversionException
【发布时间】:2019-01-16 01:32:05
【问题描述】:

我正在尝试执行以下命令的 JMeter 测试。 https://www.blazemeter.com/blog/5-ways-launch-jmeter-test-without-using-jmeter-gui

public static void main(String[] argv) throws Exception {
    // JMeter Engine
    StandardJMeterEngine jmeter = new StandardJMeterEngine();

    // Initialize Properties, logging, locale, etc.
    JMeterUtils.loadJMeterProperties("/work/apache-jmeter-5.0/bin/jmeter.properties");
    JMeterUtils.setJMeterHome("/work/apache-jmeter-5.0");
    //JMeterUtils.initLogging();// you can comment this line out to see extra log messages of i.e. DEBUG level
    JMeterUtils.initLocale();

    // Initialize JMeter SaveService
    SaveService.loadProperties();

    // Load existing .jmx Test Plan
    File in = new File("/work/apache-jmeter-5.0/extras/jmeter_test.jmx");
    HashTree testPlanTree = SaveService.loadTree(in);
    //in.close();

    // Run JMeter Test
    jmeter.configure(testPlanTree);
    jmeter.run();
}

但我总是出错

引起:com.thoughtworks.xstream.converters.ConversionException 你能帮帮我吗!

以下是详细错误:


Exception in thread "main" java.lang.IllegalArgumentException: Problem loading XML from:'/work/apache-jmeter-5.0/extras/jmeter_test.jmx'. 
Cause:
CannotResolveClassException: org.apache.jmeter.protocol.http.control.CookieManager
cause-exception     :
at org.apache.jmeter.save.ScriptWrapperConverter.createConversionException(ScriptWrapperConverter.java:102)
at org.apache.jmeter.save.ScriptWrapperConverter.unmarshal(ScriptWrapperConverter.java:96)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:70)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:134)
at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1486)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1466)
at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1337)
at org.apache.jmeter.save.SaveService.readTree(SaveService.java:452)

【问题讨论】:

    标签: java jmeter


    【解决方案1】:

    您的 JMeter 安装已损坏或您的 Java 项目配置不正确。

    1. 确保此文件存在:

      /work/apache-jmeter-5.0/lib/ext/ApacheJMeter_http.jar
      
      • 如果是 - 将其添加到您的 Java 项目类路径中:

      • 如果不是 - 你可以做的最好的事情是reinstalling JMeter。确保 verify the integrity 下载的捆绑包以检测不完整的下载。您也可以get the file separately,但是鉴于您的问题的性质,我怀疑您是否能够手动解决依赖关系,最好依赖 JMeter 安装包。

    【讨论】:

      【解决方案2】:
      猜你喜欢
      • 2017-11-28
      • 2015-08-02
      • 1970-01-01
      • 2019-01-26
      • 2021-12-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-18
      相关资源
      最近更新 更多