Test case name: testGetAllUsers, Result: pass
Exception in thread "main" java.lang.NullPointerException
at com.tutorialspoint.WebServiceTester.testGetUser(WebServiceTester.java:71)
at com.tutorialspoint.WebServiceTester.main(WebServiceTester.java:34)
The issue seems to be with this code:
I assume no value is getting passed. Can anybody advise how I might fix it?
How do you know that user is not null?
Why are you using the == operator? That will only work if the ID fields are primitives. Indent the } to the same level as if.
paul a carron wrote:User actually appears to be null. How should I deal with this?
The question should be, "What does it mean when I get to this statement and user is null?" It may be a simple as
but you can't tell without answer the question first.
All things are lawful, but not all things are profitable.
paul a carron wrote:Ah forgive me. I had made changes to some of the other classes but hadn't deployed them to Tomcat. All sorted now though.
Thanks for the help.
This hardly solves the problem. It eliminates the symptom, but not the problem probably. As been said, you should be questioning yourself why the user is null in the first place? Does your program (not code) behaves in an expected way?
What Liutauras means is that there may be a serious error if user is null. You may have corrected that in your recent deployment, but I think you should check carefully for whereever the user field is declared, and all constructors, and any setXXX methods, to make sure user won't be null again.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.