It's all about the answers!

Ask a question

Why do I get an assertion failed when getting an attribute value using the Java API?

Bruno Fazoli (856) | asked Jun 21 '15, 9:43 a.m.
edited Jun 21 '15, 10:45 a.m. by Ralph Schoon (63.2k33646)
Hi guys,

I would like to understanding an error that I'm getting.
I have a custom workitem type on my RTC instance, and I have an java application that read the workitem attributes and connect to an ERP system to perform some actions. I've noticed that If I have some workitems already created and I add a new custom attribute on the workitem configuration, the java application tries to find it on these already created workitems an return "assertion failed" stack trace. For new workitems I don't have this erros. If I delete these "old' workitems and create new ones, I don't have this problem as well

My question is: How can I manage this behavior? Imagine I have many workitems already cretead and I need to update or add a new custom attribute, I cannot delete and create all workitems again, it is not viable.

Should I have to create some pre-define custom workitems attributes and reserve them for future use avoiding creating new attributes?

Thank you in advance

sam detweiler commented Jun 21 '15, 10:50 a.m.

attributes are a PROJECT wide thing.. any workitem COULD have one of the attributes. In addition, adding attributes after workitems are created does NOT automatically force those attributesonto the old workitems. (you need to synchronize the old workitems to do this)

as Ralph mentions, there is a method to determine IF a workitem has that attributes

boolean IWorkItem.hasAttibute(IAttribute);

One answer

permanent link
Ralph Schoon (63.2k33646) | answered Jun 21 '15, 10:03 a.m.
edited Jun 21 '15, 10:04 a.m.
If you want to read an attribute use hasAttribute() first and only try to getValue, if there is one. See

You can also, in the Eclipse admin when creating the new attribute check for its usage and thus Synchronize the attributes ti the old items. Anyway, always safer to check if it has the attribute, before trying to load it.

Your answer

Register or to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.