英文:
Exception while loading JMeter test plan in code
问题
我正在尝试在Java代码中加载JMX测试计划(类似于此链接),使用以下代码:
HashTree testPlanTree = SaveService.loadTree(new File("<path-to-jmx>"));
这对于基本测试计划有效,但是,如果我加载使用任何插件(例如Arrivals Thread Group)的测试计划,它会抛出异常。这些插件已经安装在我的本地(JAR文件位于<JMETER_HOME>/lib/ext/),并且测试计划通过JMeter正常工作。
- 我们是否需要配置某些内容,使得代码能够检测测试计划中的插件并防止出现此错误?
- 我们是否可以直接从测试计划中安装插件,以便成功加载,或者至少可以获取测试计划使用的插件名称?
我收到的异常信息如下:
...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)....
英文:
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.
- Do we need to configure something for code to detect plugins in the test plan and prevent this error?
- 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)....
答案1
得分: 2
为了能够以编程方式启动 JMeter 测试,您需要在项目的 CLASSPATH 中拥有所有插件(以及它们的依赖关系)。
如果由于某些原因您无法拥有所有插件,或者插件的数量/性质不是确定的 - 至少您可以将JMeter 插件管理器添加到您的项目中,它提供了诸如getPluginStatus()
或 getAllPluginsStatus()
这样的函数,您可以用于检测已安装的插件,使用TestPlanAnalyzer来检查哪些插件是必需的,等等。
更多信息:命令行中的插件管理器
英文:
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
答案2
得分: 0
你确定没有漏掉插件的依赖项吗,比如:
- jmeter-plugins-cmn-jmeter-0.6.jar
如果没有,请展示完整的 jmeter.log 文件。
英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论