How do I access attribute values when I am receiving assertion errors through Plain Java API
![]()
I'm using the Plain Java API to grab specific details about certain work items. In the past I've been able to access custom attributes by using the workItem.getValue() function. However, some custom attributes were added recently to work items and when I attempt to access their values I'm receiving the following error:
org.eclipse.core.runtime.AssertionFailedException: assertion failed:
at org.eclipse.core.runtime.Assert.isTrue(Assert.java:110)
at org.eclipse.core.runtime.Assert.isTrue(Assert.java:96)
at com.ibm.team.workitem.common.internal.model.impl.WorkItemImpl.getValu
e(WorkItemImpl.java:2849)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:95)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:56)
at java.lang.reflect.Method.invoke(Method.java:620)
at com.ibm.team.repository.common.internal.util.ItemStore$ItemInvocation
Handler.invoke(ItemStore.java:597)
at com.sun.proxy.$Proxy21.getValue(Unknown Source)
at test.ThemeTraversal.fetchAllThemes(ThemeTraversal.java:145)
at test.RunIt.run(RunIt.java:287)
at test.RunIt.main(RunIt.java:139)
I've tested my code on a clone of the production line version and it works fine, but I can't seem to access these attributes for the production line. I'm on version 5.0.2. Anyone having similar issues?
|
3 answers
![]()
Ralph Schoon (63.3k●3●36●46)
| answered Jul 21 '15, 1:40 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
If attributes are added to work item type categories, the don't necessarily appear on work items that were created earlier. You have to synchronize the attributes to make that happen. (In the Eclipse UI there is a button Check attributes usage in repository you can use for that or check https://rsjazz.wordpress.com/2012/11/19/using-an-expression-to-synchronize-attributes-for-work-items-of-a-specific-type/ ).
In any case you should check if the work item has the attribute with hasAttribute(IAttribute). See https://rsjazz.wordpress.com/2013/01/02/working-with-work-item-attributes/ As a side note, you should not use the com.ibm.team.apt.common and com.ibm.team.apt.internal.client api unless you are working with plans (which is unsupported) use the com.ibm.team.workitem.client. and com.ibm.team.workitem.common API's that are also available in the plain Java Client Libraries. Comments Thanks for the help! I think what you said about synchronizing attributes may be the issue. The field itself has been added to the old workItems, but using Sam's code the attribute only shows up if I manually change the value of it. And once the value is changed my code works as well. Is this what you were saying? Should I still be able to see the attribute field on an old workItem even if it hasn't been synchronized? no.. unless you synch, the attribute is NOT there on old workitems.
|
![]()
my sample does check
// loop thru all the workitem attributes for (IAttribute ia : workItemCommon.findAttributes(projectArea, monitor)) { // if this workitem has this attribute and // its nOT an internal use attribute if (workItem.hasAttribute(ia) && !ia.isInternal()) Comments ![]() FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Sam, you didn't report the assertion error.
I catch the assertion error and use it to determine other attribute features
|
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.