Finally, I've found solution. It was very simple: I've extended my listener from ResultCollector.
Difficulties with extenting AbstractVisualizer: getting ClassCastException
-
11-12-2021 - |
質問
I'm developing plugin for JMeter. I want to have feature for configuring testing report, like in Simple Data Writer. For this purpose I want to extend from AbstractVisualizer, that has already implemented all functionality that I need. When I complile and run JMeter with my plugin, I'm getting error on GUI: "com.blazemeter.jmeter.testexecutor cannot be cast to org.apache.jmeter.reporters.ResultCollector" Here is code, where it occures:
/* Overrides AbstractJMeterGuiComponent.configure(TestElement) */
@Override
public void configure(TestElement el) {
super.configure(el);
setFile(el.getPropertyAsString(ResultCollector.FILENAME));
ResultCollector rc = (ResultCollector) el;
errorLogging.setSelected(rc.isErrorLogging());
successOnlyLogging.setSelected(rc.isSuccessOnlyLogging());
if (collector == null) {
collector = new ResultCollector();
}
collector.setSaveConfig((SampleSaveConfiguration) rc.getSaveConfig().clone());
}
Exact string:
ResultCollector rc = (ResultCollector) el;
Before that it worked fine(without ClassCastException) if I extended from AbstractListenerGui. Per JMeter API AbstractVisualizer is a child of AbstractListenerGui, and, as I understand, extending AbstractVisualizer instead of AbstractListenerGui should not lead to such problem. So, could you, please, help me with understanding my issue? Thank you in advance.
解決