cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

Unwritable property defined in extension package

jasong
12-Amethyst

Unwritable property defined in extension package

I have a ThingTemplate defined in a Java ext pkg, and it has lots of properties defined as well. One of those properties is "Phone", as defined by

public static final String PROPERTY_PHONE = "PhoneNumber";

I define this property like this

@ThingworxPropertyDefinition(name= Constants.PROPERTY_PHONE, description="Phone Number", baseType="STRING", aspects={"isPersistent:true","isReadOnly:false"}),

I also have code to set this property.

thing.setPropertyValue(Constants.PROPERTY_PHONE, new StringPrimitive(newValue));

This is the pattern I have for a bunch of properties, a constant defining the property name, used by the ThingworxPropertyDefinition and then the setter (and getter).

This works fine, except for this single damn property called "Phone". When I go to set this I get an empty exception with no details. In fact I cannot find any way to set this property, via Composer, REST, etc. It is unsettable.

Literally, if I change the name in the constants file from "Phone" to "Phone2", recompile, re-import, bounce tomcat, everything works. But changing back to "phone" it busts.

I have no idea how this is happening or why, and I am going to play around with defining this property in XML rather than in Java, but I am really grasping at straws here..

Any ideas out there?

4 REPLIES 4
ttielebein
14-Alexandrite
(To:jasong)

That is very odd. Have you tried creating a new project and copying the source code over and seeing if the problem exists there also? I wonder if there is some global property somewhere or some keyword called Phone which limits your ability to use that name for a property...

jasong
12-Amethyst
(To:ttielebein)

I also just learned this, if I define this in my package as "Phone2", and then add the string Property "Phone" manually to the Thing, it is not writable either. I will define this as a part of the XML on the template directly in the metadata.xml and see how it goes there

jasong
12-Amethyst
(To:jasong)

Problem found. I had some old R&D/Test code in my package that was not backed out that was preventing writing to that property. Pffhew. Thanks for the help.

ttielebein
14-Alexandrite
(To:jasong)

Awesome! I am glad you found a solution.

Announcements


Top Tags