简体   繁体   中英

java.lang.NullPointerException: Value in JsonObjects name/value pair cannot be null

I am trying to automate an E2E flow of an application. I completed the selenium scripting and it is working fine in my local. But when I am trying to run it in Jenkins , Jenkins shows below exception after compiling the program. Can you help me to get rid of it? I noticed Git download is successful and all the required files and folder names are correct.

java.io.IOException: The system cannot find the path specified
    at java.io.WinNTFileSystem.createFileExclusively(Native Method)
    at java.io.File.createNewFile(File.java:1012)
    at com.homer.logger.HomerLogger.addFileHandler(HomerLogger.java:79)
    at com.homer.logger.HomerLogger.getInstance(HomerLogger.java:45)
    at com.homer.setup.NonBDDRunner.runTCOneIteration(NonBDDRunner.java:353)
    at com.homer.setup.NonBDDRunner.runOneIteration(NonBDDRunner.java:157)
    at com.homer.interfaceimpl.NonBDDRunTestCases.runTestCase(NonBDDRunTestCases.java:63)
    at com.homer.setup.BaseRunner.executeTestCases(BaseRunner.java:122)
    at com.homer.setup.BaseRunner.executeSeleniumTestCases(BaseRunner.java:59)
    at com.homer.setup.BaseRunner.runTestCases(BaseRunner.java:41)
    at com.homer.setup.RunManager.runTestCases(RunManager.java:121)
    at com.homer.setup.RunManager.runTestCases(RunManager.java:36)
    at com.homer.runner.HomerRunner.main(HomerRunner.java:38)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:294)
    at java.lang.Thread.run(Thread.java:745)

java.lang.NullPointerException: Value in JsonObjects name/value pair cannot be null
    at org.glassfish.json.JsonObjectBuilderImpl.validateValue(JsonObjectBuilderImpl.java:164)
    at org.glassfish.json.JsonObjectBuilderImpl.add(JsonObjectBuilderImpl.java:74)
    at com.homer.reports.SummaryReport.getJsonTCObjectBuilder(SummaryReport.java:310)
    at com.homer.reports.SummaryReport.generateJSONReport(SummaryReport.java:255)
    at com.homer.reports.SummaryReport.generateFinalSummaryReport(SummaryReport.java:107)
    at com.homer.setup.RunManager.runTestCases(RunManager.java:130)
    at com.homer.setup.RunManager.runTestCases(RunManager.java:36)
    at com.homer.runner.HomerRunner.main(HomerRunner.java:38)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at ``sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:294)
    at java.lang.Thread.run(Thread.java:745)

Issue :

Your Jenkins build is trying to run the automated test cases configured in the build.xml/pom.xml . Which is using a dummy Json and while parsing it to desired pojo, Some of the pojo fields are found missing in Json. Which triggered this exception.

Fix : Adding @Nullable annotation in the pojo on top of the field which is(could be) missing in the Json/Xml will resolve this issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM