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

JMeter CLI report generation fails - org.apache.jmeter.report.dashboard.GenerationException: Data exporter "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\output082020\"
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\output082020\"
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\output082020" 
    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\output082020" 
    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\output082020" 

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

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

其次,尽量避免使用包含空格的文件夹。

我也遇到了这个错误,我的问题的解决方案是通过这个命令:

jmeter -n -t “测试文件的位置” -l “结果文件的位置” -e -o “报告文件夹的位置”

第三个选项“报告文件夹的位置”需要是一个全新的不存在的文件夹。告诉命令创建文件夹后,我的 HTML 报告成功了!

我刚刚遇到同样的错误消息,使用 jMeter 5.4.1。

就我而言,我最终使用 ProcMon

调查了问题

Procmon 显示文件夹路径中包含右双引号 ",这是 windows folder/file 名称中的无效字符。

我很幸运,我的路径中没有任何空格,所以删除双引号对我没有影响。尝试使用名称中没有空格的文件夹,或者在路径中使用 8.3 short names