簡體   English   中英

我通過Java代碼運行jmeter時出現error converters.ConversionException

[英]Error converters.ConversionException when I run jmeter by java code

我正在嘗試執行以下命令的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)

您的JMeter安裝已損壞或Java項目配置不正確。

  1. 確保此文件存在:

     /work/apache-jmeter-5.0/lib/ext/ApacheJMeter_http.jar 
    • 如果是,請將其添加到Java項目的Classpath中:

    • 如果不是,那么最好的辦法是重新安裝JMeter 請確保驗證下載的軟件包的完整性 ,以便檢測即下載不完整。 您也可以單獨獲取文件 ,但是考慮到問題的性質,我懷疑您將能夠手動解決依賴關系,因此最好依靠JMeter安裝包。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM