'Null pointer exception in Jmeter report generation in Jenkins pipeline

I am running jmeter test in non-gui mode in Jenkins pipeline.

Below are ther versions:

Jenkins agent java vaerion : 11
Jmeter version : 5.3

The command I run in Jenkins

/home/jenkins/jmeter/apache-jmeter-5.1/bin/jmeter.sh -f -n -t jmeter_scripts/Suite_master.jmx -l output.jtl -j jmeter.log -p project.properties -e -o results

However I see below failure while generating the HTML result file

2022-04-29 02:05:29,397 INFO o.a.j.r.p.CsvFileSampleSource: produce(): 1086 samples produced in 66ms on channel 0
2022-04-29 02:05:29,397 INFO o.a.j.r.d.ReportGenerator: Exporting data using exporter:'json' of className:'org.apache.jmeter.report.dashboard.JsonExporter'
2022-04-29 02:05:29,399 INFO o.a.j.r.d.JsonExporter: Found data for consumer statisticsSummary in context
2022-04-29 02:05:29,399 INFO o.a.j.r.d.JsonExporter: Creating statistics for overall
2022-04-29 02:05:29,399 ERROR o.a.j.JMeter: Error generating the report
java.lang.NullPointerException: null
    at org.apache.jmeter.report.dashboard.JsonExporter.createStatistic(JsonExporter.java:121) ~[ApacheJMeter_core.jar:5.1.1 r1855137]
    at org.apache.jmeter.report.dashboard.JsonExporter.export(JsonExporter.java:71) ~[ApacheJMeter_core.jar:5.1.1 r1855137]
    at org.apache.jmeter.report.dashboard.ReportGenerator.exportData(ReportGenerator.java:381) ~[ApacheJMeter_core.jar:5.1.1 r1855137]
    at org.apache.jmeter.report.dashboard.ReportGenerator.generate(ReportGenerator.java:262) ~[ApacheJMeter_core.jar:5.1.1 r1855137]
    at org.apache.jmeter.JMeter$ListenToTest.generateReport(JMeter.java:1324) ~[ApacheJMeter_core.jar:5.1.1 r1855137]
    at org.apache.jmeter.JMeter$ListenToTest.testEnded(JMeter.java:1261) [ApacheJMeter_core.jar:5.1.1 r1855137]
    at org.apache.jmeter.engine.StandardJMeterEngine.notifyTestListenersOfEnd(StandardJMeterEngine.java:218) [ApacheJMeter_core.jar:5.1.1 r1855137]
    at org.apache.jmeter.engine.StandardJMeterEngine.run(StandardJMeterEngine.java:492) [ApacheJMeter_core.jar:5.1.1 r1855137]
    at java.lang.Thread.run(Unknown Source) [?:?]
[Pipeline] sh

BTW I can see jtl file with data as well

-rw-r--r--. 1 jenkins jenkins 273418 Apr 29 02:05 output.jtl


Solution 1:[1]

Does your project.properties file contain the properties which are absolutely required for the report generation like jmeter.reportgenerator.apdex_satisfied_threshold and jmeter.reportgenerator.apdex_tolerated_threshold?

If not make sure they're there and contain the desired values.

If you want to pass a set of project properties replacing the original jmeter.properties file is not the best idea as apart from the aforementioned dashboard-related properties it has several more default values whose absence may lead to unexpected behaviour.

So I would recommend leaving jmeter.properties intact and using -q command line argument for passing your custom set of properties to JMeter

/home/jenkins/jmeter/apache-jmeter-5.1/bin/jmeter.sh -f -n -t jmeter_scripts/Suite_master.jmx -l output.jtl -j jmeter.log -q project.properties -e -o results

More information:

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dmitri T