Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
I have recently been doing some things in the Java SDK tutorial and I have gotten to a point where I can connect to the thingWorx hosted trial server, create a remoteThing, and bind it to a Thing that has been created in ThingWorx with the same name. What I am trying to do now is either..
A) add a property via Java code and then add values to it, this way I can update these every n seconds.
or
B) Simply add values to a property created in ThingWorx already.
For some reason when I use this code....
// Writing a property
///////////////////////////////////////////////////////////////
LocationPrimitive location = new LocationPrimitive(42.36, -71.06, 10.0);
// This will set the CurrentLocation property of the Thing to the GPS
// coordinates of Boston, MA.
client.writeProperty(ThingworxEntityTypes.Things, thingName, "CurrentLocation",
location, 5000);
I get this error...
com.thingworx.common.exceptions.GenericHTTPException: Entity TunnelExample does not exist or is not yet associated with a Thing
I am not sure how I am getting this error because if I remove the code above, everything connects fine in Java and ThingWorx. I made sure the code was executing after connecting so I am unsure why it says. Any help would be greatly appreciated as it will probably solve a number of other issues I will run into when doing this for services, events, etc...
Solved! Go to Solution.
I finally got this to work. The tutorials are a bit confusing and on top of that I had some corruption in my project configuration in Eclipse. Basically, if you have this issue, start over from scratch and use the correct import. There are 2 imports and the tutorial only shows one. I loaded both to src dir and it is working now. Also, MAKE SURE TO IMPORT THE XML INTO THINGWORX. This was the main reason mine was failing because I tried to make everything from scratch. Use the default user's app key and everything should work fine.
It is one of the example java scripts in the "java SDK tutorial". It is not directly part of this tutorial but the script is included.
The code looks like this...
//
// Writing a property
///////////////////////////////////////////////////////////////
LocationPrimitive location = new LocationPrimitive(42.36, -71.06, 10.0);
// This code sets the CurrentLocation property of the Thing to the GPS
// coordinates of Boston, MA.
client.writeProperty(ThingworxEntityTypes.Things, ThingName, "CurrentLocation",
location, 5000);
LOG.info("Wrote to the property 'CurrentLocation' of Thing {}. value: {}",
ThingName, location.toString());
I finally got this to work. The tutorials are a bit confusing and on top of that I had some corruption in my project configuration in Eclipse. Basically, if you have this issue, start over from scratch and use the correct import. There are 2 imports and the tutorial only shows one. I loaded both to src dir and it is working now. Also, MAKE SURE TO IMPORT THE XML INTO THINGWORX. This was the main reason mine was failing because I tried to make everything from scratch. Use the default user's app key and everything should work fine.
Hi @justinoberle.
I'm glad you were able to resolve your issue.
It would be helpful if you could provide the link to the tutorial you were using so we can engage the correct team for improvements.
Thank you for your participation in our community!
Regards.
--Sharon