It's all about the answers!

Ask a question

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

Sergio Felix (11) | asked Sep 16 '15, 11:37 a.m.
 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: 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?

2 answers

permanent link
sam detweiler (12.5k6195201) | answered Sep 16 '15, 11:39 a.m.
you have to reload the process object and get a new working copy..   once you 'save' thru the working copy, it becomes invalid.

Sergio Felix commented Sep 16 '15, 11:52 a.m.


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.

sam detweiler commented Sep 16 '15, 12:08 p.m.

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

Sergio Felix commented Sep 17 '15, 4:02 a.m.

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);
        return response;

The problem occurs when a request to edit a IProcessAreaWorkingCopy happens. The problem is that even if the; 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.

sam detweiler commented Sep 17 '15, 6:43 a.m.

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.

Sergio Felix commented Sep 17 '15, 7:47 a.m.

 Can you share how are you retrieving the IProcessAreaWorkingCopy? Can you tell me if you do something other then; at the end of your changes?

permanent link
sam detweiler (12.5k6195201) | answered Sep 17 '15, 7:56 a.m.
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);
                    // save all the new/modified objects to the repository
          , null);
                catch (Exception ex)
                    if (!ex.getMessage().contains("Duplicate"))
                        System.out.println("exception=" + ex.getMessage());

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.