It's all about the answers!

Ask a question

Question on discussion Attribute for a RTC work item using Plain Java API

premkumar sankaranarayanan (512) | asked Jan 07 '20, 10:06 a.m.

 hi , did anyone extract data from discussion field in a RTC work item using Plain JAVA API’s? I created small application which is extracting some fields but could not able to pull the discussion data due to assertion failures. Did anyone try this? Please advise. Thank you.

Exception in thread "main" org.eclipse.core.runtime.AssertionFailedException: assertion failed: 
at org.eclipse.core.runtime.Assert.isTrue(
at org.eclipse.core.runtime.Assert.isTrue(
at sun.reflect.GeneratedMethodAccessor18.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at com.sun.proxy.$Proxy22.getValue(Unknown Source)
at CiasQrtc.ExpandWorkitems(
at CiasQrtc.processUnresolvedResults(
at CiasQrtc.findPersonalQuery(
at CiasQrtc.main(

Accepted answer

permanent link
Ralph Schoon (61.4k33643) | answered Jan 08 '20, 2:19 a.m.
edited Jan 08 '20, 3:52 a.m.
Sorry, I somehow missed the point.

The Discussion is not a real attribute. It is a collection of (comment) objects. Here how I access it.

     * Convert the comments data into a string containing all the comments
     * @param workItem
     * @return
     * @throws TeamRepositoryException
    private String calculateCommentsAsString(IWorkItem workItem) throws TeamRepositoryException {

        IComments comments = workItem.getComments();
        IComment[] theComments = comments.getContents();
        List<string> commentText = new ArrayList<string>(theComments.length);
        int i = 1;
        for (IComment aComment : theComments) {
            if (i > 1) {
            commentText.add(i + ". " + getCommentAsString(aComment));
        return StringUtil.listToString(commentText, SEPERATOR_NEWLINE);


This is how to get the content of the comment:

     * Get one comment as string
     * @param aComment
     * @return
     * @throws TeamRepositoryException
    private String getCommentAsString(IComment aComment) throws TeamRepositoryException {
        String creator = calculateContributorAsString(aComment.getCreator());
        String creationDate = calculateTimestampAsString(aComment.getCreationDate());
        return creator + " - " + creationDate + SEPERATOR_NEWLINE + aComment.getHTMLContent().getPlainText();

premkumar sankaranarayanan selected this answer as the correct answer

3 other answers

permanent link
Ralph Schoon (61.4k33643) | answered Jan 07 '20, 11:38 a.m.
I have been always able to get the description. Since there is no hint which code fails, not able to speculate what goes wrong.

There is a dedicated API for the description, that can be used as well. shows how to get and set it. It is available for the summary as well.

there is a getter as well. You should be able to use the IAttribute as well, check what the object type is.

premkumar sankaranarayanan commented Jan 07 '20, 3:26 p.m.

could not able to respond you here because of some restrictions. Posted my response below


permanent link
premkumar sankaranarayanan (512) | answered Jan 07 '20, 3:25 p.m.

 Hi Ralph, Thank you for taking some time in responding .

I referred all these items before but could not able to resolve the specific issue am facing. 
I'm trying to fetch the Custom Attribute called discussion which is of type html.
I pulled the source code of WorkitemImpl and looked into the method where it is failing. It looks like it is failing at the Assertion where it is checking whether the attribute is present or not and I guess it is failing right exactly there. I'm not quite sure if there would be a list of custom and built-in attributes which can compared to check for fetching the work item attribute to get data. 
public Object getValue(IAttribute attribute) {

permanent link
Dino Jurina (11) | answered Jul 03 '20, 11:30 a.m.
edited Jul 03 '20, 11:31 a.m.


I'm getting almost the same error, using rtc plain java api 6.0.5: 

org.eclipse.core.runtime.AssertionFailedException: assertion failed: 
at org.eclipse.core.runtime.Assert.isTrue( ~[org.eclipse.equinox.common_3.6.100.v20120522-1841-6.0.5.jar:na]
at org.eclipse.core.runtime.Assert.isTrue( ~[org.eclipse.equinox.common_3.6.100.v20120522-1841-6.0.5.jar:na]
at ~[]
at sun.reflect.GeneratedMethodAccessor102.invoke(Unknown Source) ~[na:na]
at sun.reflect.DelegatingMethodAccessorImpl.invoke( ~[na:1.8.0_232]
at java.lang.reflect.Method.invoke( ~[na:1.8.0_232]
at$ItemInvocationHandler.invoke( ~[]
at com.sun.proxy.$Proxy145.getValue(Unknown Source) ~[na:na]
at ~[fria-automation-0.0.1-SNAPSHOT.spring:na]

It happens on one property in one specific project area.
I'm successfully getting values from other properties in that project area and I'm fetching the value of that same property in another project area created with the same template. 

The error pops out on the last line of this block (final Object propertyValue = workItem.getValue(attribute); - is the line 115 where I am getting errors)

 And it's very strange because findAttributes() returns the attribute as one of the possible attributes, but workItem.getValue(attribute) throws the exception saying that the attribute is not available on the work item.

Any guidances?
final List<IAttribute> attributes = workItemClient.findAttributes(projectArea, monitor);

for (final String propertyName : propertyNames) {
for (IAttribute attribute : attributes) {
if (propertyName.equals(attribute.getDisplayName())) {
final Object propertyValue = workItem.getValue(attribute);


Ralph Schoon commented Jul 03 '20, 12:30 p.m.
  1. Conver this in your own question
  2. Just because an attribute is defined for a work item type, it does not necessarily be  available on all of these items. You can test with workItem.hasAttribute(attribute)

Dino Jurina commented Jul 03 '20, 3:18 p.m.

Hi Ralph,
thanks for quick answer.

I am 100% that i saw on the RTC GUI that the work item on which I'm getting the error has the attribute on which the error is shown.

I'll check if the hasAttribute() method returns 'true' on Monday when I get the access to client's environment.

But, what bothers me is that I obviously can't change that attribute on that work item (because of this error).

Do you have any other guidances? 

I'll convert this to my own question on Monday when I'll have additional information.

Ralph Schoon commented Jul 06 '20, 4:19 a.m.
Unless you have more data, I don't have anything. My suggestions are on my blog e.g.

You could try using the WCL to see if it has the same issue. The WCL also has a lot of example code for reading and updating work items.

Dino Jurina commented Jul 06 '20, 8:38 a.m.

Thanks for your suggestions.

In the end it turned out that client has two attributes with the same display name, but different id in project area. 
Problem was solved with requesting client to enter attribute ids instead of display names.

Ralph Schoon commented Jul 06 '20, 8:50 a.m.

Good advice. I would consider it a best practice.

Your answer

Register or to post your answer.