1
votes

I'm trying to load a jmx test plan in Java code (similar to this) using -

HashTree testPlanTree = SaveService.loadTree(new File("<path-to-jmx>"));

It works for basic test plan but, if I load a test plan using any plugin like Arrivals Thread group, it throws an exception. The plugins are installed on my local (jars are present in <JMETER_HOME>/lib/ext/) and the test plan is working fine via jmeter.

  1. Do we need to configure something for code to detect plugins in the test plan and prevent this error?
  2. Can we install plugins from the test plan directly using any api for successful loading or at least get the names of plugins used by the test plan?

Exception I get -

...Exception in thread "main" java.lang.IllegalArgumentException: Problem loading XML from:'<path-to-jmx>'.
Cause:
CannotResolveClassException: com.blazemeter.jmeter.threads.arrivals.ArrivalsThreadGroup

 Detail:com.thoughtworks.xstream.converters.ConversionException:
---- Debugging information ----
cause-exception     : com.thoughtworks.xstream.converters.ConversionException
cause-message       :
first-jmeter-class  : org.apache.jmeter.save.converters.HashTreeConverter.unmarshal(HashTreeConverter.java:66)
class               : org.apache.jmeter.save.ScriptWrapper
required-type       : org.apache.jmeter.save.ScriptWrapper
converter-type      : org.apache.jmeter.save.ScriptWrapperConverter
path                : /jmeterTestPlan/hashTree/hashTree/com.blazemeter.jmeter.threads.arrivals.ArrivalsThreadGroup
line number         : 64
version             : 5.3
-------------------------------
        at org.apache.jmeter.save.SaveService.readTree(SaveService.java:458)
        at org.apache.jmeter.save.SaveService.loadTree(SaveService.java:431)....
2

2 Answers

2
votes

In order to be able to launch JMeter test programmatically you need to have all the plugins (as well as their dependencies) in your project CLASSPATH

If for some reason you cannot have all the plugins or their number/nature is not deterministic - at least you could add JMeter Plugins Manager to your project, it provides functions like getPluginStatus() or getAllPluginsStatus() which you can use for detection of installed plugins, use TestPlanAnalyzer to check which ones are required, etc.

More information: Plugins Manager from Command-Line

0
votes

Are you sure you're not missing a dependency of the plugin like:

  • jmeter-plugins-cmn-jmeter-0.6.jar

If not, please show full jmeter.log file