Skip to main content
1-Visitor
May 18, 2017
Question

How to handle java null pointer exceptions

  • May 18, 2017
  • 3 replies
  • 6050 views

Hey There,

I was working on this very simple service that I wrote for ThingShapes.

All I am doing is "Updating a Thing's Property". However, I keep getting java.lang.NullPointerException Cause: Null,

my Service on the Thing is following:

if(Contact){

Things[uuid].Contact = Contact;

}

if(Contact_Phone){

Things[uuid].Contact_Phone = Contact_Phone;

}

if(MyName){

Things[uuid].MyName = MyName;

}

if(phyLocation){

Things[uuid].phyLocation = phyLocation;

}

if(freq){

Things[uuid].freq = freq;

}

I am not sure what I am doing wrong.

3 replies

20-Turquoise
May 18, 2017

Without looking at your code first, what are the input and output types specified for the service?

mbereket1-VisitorAuthor
1-Visitor
May 18, 2017

No Outputs, all string inputs

1-Visitor
May 18, 2017

you can put few console.log() to check if any prop values are getting as null.

Also you can check the spell of Propery names if those are correct.

20-Turquoise
May 19, 2017

Try putting a space after the "if"s.

mbereket1-VisitorAuthor
1-Visitor
May 22, 2017

Tried but didn't change the result.

20-Turquoise
May 19, 2017

I've actually just tried running your service and it works. Could you please export your entity and email it to me to posipova@ptc.com ? I will check to see if everything was saved/declared properly.