Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X
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.
Without looking at your code first, what are the input and output types specified for the service?
No Outputs, all string inputs
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.
I tried putting logs. but that Null Pointer problem appearntly comes up before my log outputs. So, I can see nothing but that Null Exception in the logs.
Hi, to catch the error, can you try to wrap your code with:
try {
...your code...
}
catch (e) {
logger.debug("Line " + e.lineNumber + ": " + e);
}
Hi mustafa bereket,
This service works fine for me. Which ThingWorx version you are on?
Please check Application logs for more details.
Points to check:
1. Make sure the Thing where service is being tested is saved.
2. Make Sure uuid is given a correct ThingName.
3. User has Visibility/RunTime Permissions to the Thing.
Are you able to run any service on this Thing? Also, try restarting your Tomcat once to avoid any caching issue.
Application/Script logs will give better insight on the issue.
I hop it helps.
Try putting a space after the "if"s.
Tried but didn't change the result.
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.