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

Unable to save the same ProjectAreaWorkingCopy twice in a row. Stale Exception.

 I've been trying to programatically change the process configuration XML. I've done it successfully, however I run into a problem when my application gets multiple requests to save in the same Project Area. 

The problem that I have is that the save method returns successfully. Another request starts and then I get a:

com.ibm.team.repository.common.StaleDataException: UpdateItemCurrentRow failure:  Params=[_WHQxglx_EeWFo6onmSus9Q,_uakdUNQmEeK9uYPg6dqTSg,_UqClklx_EeWFo6onmSus9Q]

Whats even stranger is that even tho the exception is thrown, the item gets saved correctly to the file. Is there a way to manually synchronize the save? Make sure its really really saved? Can I test if there is a save in progress?

I've already tried all sorts of tricks like checking if isDirty() before I try saving but nothing works. Help?

0 votes



2 answers

Permanent link
you have to reload the process object and get a new working copy..   once you 'save' thru the working copy, it becomes invalid.

0 votes

Comments

Hello!


So every time there is a new request, a new connection is made, I fetch the process object, get a new working copy and then save.

can u describe a little more where the request comes in.. is this is a server plugin?

Its a stand alone Java application using the Java API, requests come in from Spring Integration. The request instantiates a new RTC connection, and a new class that handles PAInformation related stuff:


RtcConnection con = new RtcConnection(url, user, pass);
        ProjectAreaInformationServiceImpl paInfoService = new ProjectAreaInformationServiceImpl(con);
        String response = paInfoService.doSomething(paName, someObject);
        con.close();
        return response;

The problem occurs when a request to edit a IProcessAreaWorkingCopy happens. The problem is that even if the projectAreaWorkingCopy.save(null); has finished doing its thing, and the connection is closed, it leaves the PA in an awkward state. The next request comes in and BOOM! Stale Data exception.



as these are private classes, its hard to help without much more detail.

I have a plain java utility that updates the process area multiple times in the same run, so it can be done.

 Can you share how are you retrieving the IProcessAreaWorkingCopy? Can you tell me if you do something other then projectAreaWorkingCopy.save(null); at the end of your changes?


Permanent link
I don't use the processarea directly..

I use the ProcessItem Client
                private static IProcessItemService destprocessItemClient = null;
                destprocessItemClient = (IProcessItemService) repo.getClientLibrary(IProcessItemService.class);

                // allocate arraylist to hold list of modified objects.. all have to be saved at one time.
                ArrayList<IProcessItem> newitemlist = new ArrayList<IProcessItem>();

                // add the project to the list
                newitemlist.add((new IProcessItem[] { iprja_dest })[0]);

do work, add modified items (working copies) to the arraylist as you go

                // allocate space for the array
                IProcessItem[] ilist = new IProcessItem[newitemlist.size()];
                // build the arrary
                ilist = newitemlist.toArray(ilist);
                try
                {
                    // save all the new/modified objects to the repository
                    destprocessItemClient.save(ilist, null);
                }
                catch (Exception ex)
                {
                    if (!ex.getMessage().contains("Duplicate"))
                        System.out.println("exception=" + ex.getMessage());
                }

0 votes

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: Sep 16 '15, 11:37 a.m.

Question was seen: 2,428 times

Last updated: Sep 17 '15, 7:56 a.m.

Confirmation Cancel Confirm