JMeter CLI报告生成失败-org.apache.jmeter.report.dashboard.GenerationException:数据导出器“ json”

问题描述

JMeter 5.3

我使用CLI如下:

C:\Users\guyl\OneDrive - xxxxLTD\Guy\apache-jmeter-5.3\bin>jmeter -n -t "C:\Users\guyl\OneDrive - xxxxLTD\Guy\JMeter\DCS DB threaded test.jmx"  -l"C:\Users\guyl\OneDrive - xxxxLTD\Guy\JMeter\db_report.csv" -Jthreads=5 -Jloops=100 -e -o"C:\Users\guyl\OneDrive - xxxxLTD\Guy\JMeter\output\19082020\"
Creating summariser <summary>
Created the tree successfully using C:\Users\guyl\OneDrive - xxxLTD\Guy\JMeter\DCS DB threaded test.jmx
Starting standalone test @ Wed Aug 26 14:22:56 IDT 2020 (1598440976507)
Waiting for possible Shutdown/StopTestNow/HeapDump/ThreadDump message on port 4445
Generate Summary Results +     91 in 00:00:03 =   32.0/s Avg:    35 Min:     0 Max:  1031 Err:     0 (0.00%) Active: 2 Started: 2 Finished: 0
summary +     91 in 00:00:03 =   32.1/s Avg:    35 Min:     0 Max:  1031 Err:     0 (0.00%) Active: 2 Started: 2 Finished: 0
summary + 104409 in 00:00:29 = 3621.4/s Avg:     1 Min:     0 Max:   448 Err: 50400 (48.27%) Active: 0 Started: 5 Finished: 5
summary = 104500 in 00:00:32 = 3299.8/s Avg:     1 Min:     0 Max:  1031 Err: 50400 (48.23%)
Generate Summary Results + 104409 in 00:00:29 = 3620.9/s Avg:     1 Min:     0 Max:   448 Err: 50400 (48.27%) Active: 0 Started: 5 Finished: 5
Generate Summary Results = 104500 in 00:00:32 = 3299.1/s Avg:     1 Min:     0 Max:  1031 Err: 50400 (48.23%)
Tidying up ...    @ Wed Aug 26 14:23:28 IDT 2020 (1598441008843)
Error generating the report: org.apache.jmeter.report.dashboard.GenerationException: Data exporter "json" is unable to export data.
... end of run

最后,您可以看到我们拥有:

Error generating the report: org.apache.jmeter.report.dashboard.GenerationException: Data exporter "json" is unable to export data.
... end of run

请注意,报告的扩展名是CSV还是JTL都没关系。

能够生成JTL报告,然后运行jmeter -g <my JTL file>,但是我想使用-e选项。

更新:现在,我在使用g选项时遇到了错误

C:\Users\guyl\OneDrive - xxxLTD\Guy\apache-jmeter-5.3\bin>jmeter -g "C:\Users\guyl\OneDrive - xxxLTD\Guy\JMeter\db_report" -o"C:\Users\guyl\OneDrive - xxxLTD\Guy\JMeter\output\19082020\"
An error occurred: Data exporter "json" is unable to export data.
errorlevel=1
Press any key to continue . . .

这是我在jmeter.log文件中找到的内容

2020-08-26 14:37:51,812 INFO o.a.j.r.p.AbstractSampleConsumer: class org.apache.jmeter.report.processor.FilterConsumer#stopProducing(): nameFilter produced 1567500 samples
2020-08-26 14:37:51,812 INFO o.a.j.r.p.AbstractSampleConsumer: class org.apache.jmeter.report.processor.FilterConsumer#stopProducing(): daterangeFilter produced 313500 samples
2020-08-26 14:37:51,812 INFO o.a.j.r.p.AbstractSampleConsumer: class org.apache.jmeter.report.processor.normalizerSampleConsumer#stopProducing(): normalizer produced 104500 samples
2020-08-26 14:37:51,813 INFO o.a.j.r.p.CsvFileSampleSource: produce(): 104500 samples produced in 6s 70 ms on channel 0
2020-08-26 14:37:51,813 INFO o.a.j.r.d.ReportGenerator: Exporting data using exporter:'json' of className:'org.apache.jmeter.report.dashboard.JsonExporter'
2020-08-26 14:37:51,814 INFO o.a.j.r.d.JsonExporter: Found data for consumer statisticsSummary in context
2020-08-26 14:37:51,814 INFO o.a.j.r.d.JsonExporter: Creating statistics for overall
2020-08-26 14:37:51,815 INFO o.a.j.r.d.JsonExporter: Creating statistics for other transactions
2020-08-26 14:37:51,815 INFO o.a.j.r.d.JsonExporter: Checking output folder
2020-08-26 14:37:51,816 ERROR o.a.j.JMeter: An error occurred: 
org.apache.jmeter.report.dashboard.GenerationException: Data exporter "json" is unable to export data.
    at org.apache.jmeter.report.dashboard.ReportGenerator.exportData(ReportGenerator.java:385) ~[ApacheJMeter_core.jar:5.3]
    at org.apache.jmeter.report.dashboard.ReportGenerator.generate(ReportGenerator.java:258) ~[ApacheJMeter_core.jar:5.3]
    at org.apache.jmeter.JMeter.start(JMeter.java:545) [ApacheJMeter_core.jar:5.3]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_241]
    at sun.reflect.NativeMethodAccessorImpl.invoke(UnkNown Source) ~[?:1.8.0_241]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(UnkNown Source) ~[?:1.8.0_241]
    at java.lang.reflect.Method.invoke(UnkNown Source) ~[?:1.8.0_241]
    at org.apache.jmeter.NewDriver.main(NewDriver.java:252) [ApacheJMeter.jar:5.3]
Caused by: org.apache.jmeter.report.dashboard.ExportException: Error creating output folder C:\Users\guyl\OneDrive - Nayax LTD\Guy\JMeter\output\19082020" 
    at org.apache.jmeter.report.dashboard.JsonExporter.checkAndGetoutputFolder(JsonExporter.java:112) ~[ApacheJMeter_core.jar:5.3]
    at org.apache.jmeter.report.dashboard.JsonExporter.export(JsonExporter.java:77) ~[ApacheJMeter_core.jar:5.3]
    at org.apache.jmeter.report.dashboard.ReportGenerator.exportData(ReportGenerator.java:379) ~[ApacheJMeter_core.jar:5.3]
    ... 7 more
Caused by: java.io.IOException: Unable to create directory C:\Users\guyl\OneDrive - xxxLTD\Guy\JMeter\output\19082020" 
    at org.apache.commons.io.FileUtils.forceMkdir(FileUtils.java:2491) ~[commons-io-2.6.jar:2.6]
    at org.apache.jmeter.report.dashboard.JsonExporter.checkAndGetoutputFolder(JsonExporter.java:110) ~[ApacheJMeter_core.jar:5.3]
    at org.apache.jmeter.report.dashboard.JsonExporter.export(JsonExporter.java:77) ~[ApacheJMeter_core.jar:5.3]
    at org.apache.jmeter.report.dashboard.ReportGenerator.exportData(ReportGenerator.java:379) ~[ApacheJMeter_core.jar:5.3]
    ... 7 more

所以这一切都始于:

Caused by: java.io.IOException: Unable to create directory C:\Users\guyl\OneDrive - xxx LTD\Guy\JMeter\output\19082020" 

应该创建该文件夹(如果不存在),不是吗?

解决方法

JMeter将仅创建1级文件夹,而不是整个层次结构。

第二,尝试避免在其中放置空格的文件夹。