简体   繁体   中英

Error converters.ConversionException when I run jmeter by java code

I'm trying to execute the JMeter test which the following command. 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();
}

But I always get an error

Caused by : com.thoughtworks.xstream.converters.ConversionException Could you please help me!

And below is detail error:


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)

Either your JMeter installation is corrupt or your Java project configuration is incorrect.

  1. Make sure that this file is present:

     /work/apache-jmeter-5.0/lib/ext/ApacheJMeter_http.jar 
    • If it is - add it to your Java project Classpath:

    • If it is not - the best thing you could do is reinstalling JMeter . Make sure to verify the integrity of the downloaded bundle in order to detect ie incomplete download. You can also get the file separately , however given the nature of your question I doubt you will be able to resolve dependencies manually, it's better to rely on JMeter installation bundle.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM