It's all about the answers!

Ask a question

getting Validation error "PropertyConstraintException:Duplicate item references are not allowed: customAttributes " on saving workItem -Server side plugin


lakshmi jyothsna (3716) | asked Dec 07 '16, 4:51 a.m.
edited Dec 07 '16, 4:59 a.m.
I am working on a RTC server-side plugin which basically updates  the value of a custom attribute  in its parent’s  work-item. It works fine till one level of hierarchy i.e if a work-item has only parent and fails while updating its grand parent.
It  fails with the following  exception  :

//exception stack

2016-12-04 22:12:19,246 [http-bio-9443-exec-5 @@ 22:12 myadmin <com.ibm.team.repository.transport.client.RemoteTeamService spnego-enabled@127.0.0.1> /ccm/service/com.ibm.team.workitem.common.internal.IWorkItemRepositoryService] ERROR com.ibm.team.process.common                         - Validation errors for item: type = WorkItem, itemId = [UUID _ISui0LobEeaQdoRl3qgW5A]
    Duplicate item references are not allowed: customAttributes
com.ibm.team.repository.common.validation.PropertyConstraintException: Validation errors for item: type = WorkItem, itemId = [UUID _ISui0LobEeaQdoRl3qgW5A]
    Duplicate item references are not allowed: customAttributes
    at com.ibm.team.repository.service.internal.RdbRepositoryDataMediator.failIfNecessary(RdbRepositoryDataMediator.java:467)
    at com.ibm.team.repository.service.internal.RdbRepositoryDataMediator.validateItem(RdbRepositoryDataMediator.java:416)
    at com.ibm.team.repository.service.internal.RdbRepositoryDataMediator.validateItemWithPossibleRewrites(RdbRepositoryDataMediator.java:436)
    at com.ibm.team.repository.service.internal.RdbRepositoryDataMediator.createImmutablePersistentCopy(RdbRepositoryDataMediator.java:1688)
    at com.ibm.team.repository.service.internal.RdbRepositoryDataMediator.createImmutablePersistentCopyForSave(RdbRepositoryDataMediator.java:1651)
    at com.ibm.team.repository.service.internal.RdbRepositoryDataMediator.saveAuditable(RdbRepositoryDataMediator.java:890)


.


Eg:

I have task WI whose parent is Feature and grand parent is Story  .I have created three custom attributes mapped to each of these WI Types.
On save of task  WI  ,if the value of custom attribute has changed my  participant in subject   is trying to update another custom attribute of Feature which is successful but fails in updating  the custom attribute of Story with the above mentioned exception .


I have followed the https://rsjazz.wordpress.com/2012/07/31/rtc-update-parent-duration-estimation-and-effort-participant/ example and  trying to update the custom attributes of the parent work items in the hierarchy.

Does any one can help why the exception occurs and how to resolve  it ?

Thanks for the help in advance ..

One answer



permanent link
Ralph Schoon (63.2k33646) | answered Dec 07 '16, 6:40 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
 You apparently do somethign with the API that you better should not. Not sure how you could introduce duplicate references and what that actually is. I have never had that problem.

 - Validation errors for item: type = WorkItem, itemId = [UUID _ISui0LobEeaQdoRl3qgW5A] 
    Duplicate item references are not allowed: customAttributes 
com.ibm.team.repository.common.validation.PropertyConstraintException: Validation errors for item: type = WorkItem, itemId = [UUID _ISui0LobEeaQdoRl3qgW5A] 
    Duplicate item references are not allowed: customAttributes 

Maybe you try to add the same attribute on different work items. No Idea. 

Comments
lakshmi jyothsna commented Dec 14 '16, 6:28 a.m. | edited Nov 16 '17, 9:21 a.m.

 Hi Ralph,

Thanks for the response !!

 Please find the below code which is failing on saving the ‘grand-parent’ of current WI.


IWorkItem currentTWorkItem = // get from new state 
While(true) {
  IWorkItem parentHandle =findparentHandle( <wbr> currentTWorkItem);
 if(parentHandle!=null) {
IWorkItem parentWorkItem = (IWorkItem) fWorkItemServer. <wbr> getAuditableCommon().
                                resolveAuditable( <wbr> parentWorkItemHandle, 
                                        IWorkItem.FULL_PROFILE, monitor).getWorkingCopy();

IAttribute parentAttributeObj = //find parentAttributeObject which We want to update
parentWorkItem.setValue( <wbr> parentAttributeObj,newValue);
IStatus status = fWorkItemServer.saveWorkItem2( <wbr> parentWorkItem, null,null);
                    if(status.isOK()){
                        System.out.println("Save successful");
                    } else {
            //report error
                }
currentTWorkItem =  parentHandle  //setting  parent as current     work item to find  its parent (grand-parent)
} else {
 //no parent ..break from loop 
}

}

As we can see my parentHandle and parentAttributeObj is not same always.But still its throwing the subject line exception.

Thanks in advance!!


Ralph Schoon commented Dec 14 '16, 8:01 a.m. | edited Nov 16 '17, 9:21 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

I am not going to debug your plugin. Sorry, but this is basically not possible.

However, I will say that the code above will cause various problems and will in fact also crash your RTC server. Each Work Item Save in the participant will cause another work item save and so forth. Each of those saves will trigger your operational behavior again. It will basically recursively go on and on until your server crashes.

See RTC Update Parent Duration Estimation and Effort Participant and other participants on that blog for how to prevent that.

I think this is probably a poor design and you might want to use the recursive behavior to set the attribute.

I don't know what attribute type you use and what actually causes the error.

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.