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

how to ressolve com.ibm.team.repository.common.StaleDataException ?

Hello  Team

i am Creating Iterations automatically using client libraries .

I want to generate 2 iteartion at a time ,i am able to create one iteartion successfully when it tries to create the second iteration it throws me an error :

Exception in thread "main" com.ibm.team.repository.common.StaleDataException: CRJAZ0223I The following item has been changed by another operation:
Input
: com.ibm.team.process.internal.common.impl.DevelopmentLineImpl@3fb40234 (stateId: [UUID _lTUeM-FtEeaiosrJ0FhAzA], itemId: [UUID _bSq88AanEeS0iaGUWBwblA], origin: <unset>, immutable: true) (contextId: [UUID _ltV88T_eEeO3W9y9iL4-mw], modified: 2017-01-23 14:12:25.235, workingCopy: <unset>) (mergePredecessor: null, workingCopyPredecessor: <unset>, workingCopyMergePredecessor: <unset>, predecessor: [UUID _SyzJUOFtEeaiosrJ0FhAzA]) (name: Development Timeline, id: Function Team 1, descSummary: , archived: false, internalStartDate: null, internalEndDate: null)
Current: com.ibm.team.process.internal.common.impl.DevelopmentLineImpl@87319ec (stateId: [UUID _lQ74keFtEeaiosrJ0FhAzA], itemId: [UUID _bSq88AanEeS0iaGUWBwblA], origin: <unset>, immutable: true) (contextId: [UUID _ltV88T_eEeO3W9y9iL4-mw], modified: 2017-01-23 14:12:24.985, workingCopy: <unset>) (mergePredecessor: null, workingCopyPredecessor: <unset>, workingCopyMergePredecessor: <unset>, predecessor: [UUID _SyzJUOFtEeaiosrJ0FhAzA]) (name: Development Timeline, id: Function Team 1, descSummary: , archived: false, internalStartDate: null, internalEndDate: null)

below is my code used to create itearation :
IProcessItemService service = (IProcessItemService)AutoIteration.teamRepository
                .getClientLibrary(IProcessItemService.class);

        IIteration newIteration = (IIteration) IIteration.ITEM_TYPE
                .createItem();
         IdCreator idcreator=new IdCreator();
   
    String[] details=    idcreator.getIdDetails();
       
        newIteration.setName(details[0]);
        newIteration.setId(details[0]+details[1]);
        try {
            newIteration.setStartDate(sdf.parse(details[1]));
        } catch (ParseException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        try {
            newIteration.setEndDate(sdf.parse(details[2]));
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
       
        IIterationHandle iIterationHandle1 = newIteration;
        AutoIteration.developmentLine.insertIterationAfter(newIteration, iIterationHandle1);

        AutoIteration.developmentLine.addIteration((IIterationHandle) newIteration
                .getItemHandle());

        newIteration.setDevelopmentLine(AutoIteration.developmentLine);

        IProgressMonitor monitor = null;
       
        service.save(new IProcessItem[] { AutoIteration.developmentLine, newIteration },
                (org.eclipse.core.runtime.IProgressMonitor) monitor);
       
   

 

0 votes


Accepted answer

Permanent link

Stale data exception means, that an object has been modified compared to the version that is currently saved. The best hint I can give is to resolve the items before doing the next save. For example resolve the timeline after the save. See https://rsjazz.wordpress.com/2013/03/20/understanding-and-using-the-rtc-java-client-api/ for hints for some of these topics.

Ralph Schoon selected this answer as the correct answer

0 votes

Comments

Exactly, you probably need to re-fetch the developmentLine so that you are working with the latest copy, and then try to add the iteration to that.

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,941

Question asked: Jan 23 '17, 8:14 a.m.

Question was seen: 2,910 times

Last updated: Jan 11 '19, 4:32 p.m.

Confirmation Cancel Confirm