Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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?

0 votes



3 answers

Permanent link
see my little sample here  https://jazz.net/forum/questions/94776/assertionfailedexception-problem-with-getting-the-values-of-attributes

which prints out the attributes of workitems from a query result


1 vote

Comments

 Where are you getting the com.ibm.team.apt.common and com.ibm.team.apt.internal.client apis? They weren't in the Plain Java jar files I found on the jazz website

those are in the SDK.
you could remove them and comment out the code

 Thanks for the help! I tried your code and it initially didn't find the attribute for the work item. Once I set a value for the attribute though it found it with no problem. I assumed if I could see the field in workItem online, I should be able to access it. But I can only access it if it was assigned a value. 

hm.. the code should always print an attributes value even when null.

it does NOT print user names, or data/time values.

what kind of attribute is it?


Permanent link
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.

1 vote

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.


Permanent link
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())

0 votes

Comments

Sam, you didn't report the assertion error.

I catch the assertion error and use it to determine other attribute features

.....
// this will throw exception if not enumeration
                            IEnumeration<iliteral> enumeration = (IEnumeration<iliteral>) workItemCommon
                                    .resolveEnumeration(ia, monitor);



  catch (Exception e)
                    {
                        System.out.println("\t\t\t\tattribute id="
                           

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,938

Question asked: Jul 20 '15, 4:51 p.m.

Question was seen: 2,999 times

Last updated: Jul 21 '15, 2:55 p.m.

Confirmation Cancel Confirm