Hi Greg,
Try with the following variation.
Farrukh
On 2010-07-08, at 5:49 PM, Greg Lappen wrote:
> Ah, yes, thanks for catching that. I fixed that and re-tested, and I still
> get the 20 second delay. The code now looks like:
>
>
> public class LPFile extends _LPFile {
> ....
> ....
> public synchronized void setFileData(NSData fileData) throws IOException {
> // Update forms by deleting existing ones, then adding new ones
> for (int i=lpFileForms().count()-1; i>=0; i--) {
> final LPFileForm lpFileForm = (LPFileForm)
> lpFileForms().objectAtIndex(i);
> this.removeFromLpFileForms(lpFileForm);
> editingContext().deleteObject(lpFileForm);
> }
>
// Modify the above loop as follow and after deletion execute
editingContext().saveChanges().
for(LpFileForm lpForm : lpFileForms()) {
lpForm.delete();
}
editingContext().saveChanges();
> // Get new form list via SOAP call
> Element docInfoElm = LPServer.threadLocal().exportDocumentInfo(this);
>
> List formElms = formsElm.getChildren("form");
> for (int i = 0; i < formElms.size(); i++) {
> Element formElm = (Element) formElms.get(i);
> LPFileForm lpFileForm = new LPFileForm();
> editingContext().insertObject(lpFileForm);
>
> // extract data from xml, put into lpFileForm
>
> // Setup relationships to lpForm and lpFile
> lpFileForm.setLpForm(lpForm);
> lpFileForm.setLpFormID(lpForm.id());
> lpFileForm.setLpFile(this);
> lpFileForm.setLpFileID(this.fileID());
>
> this.addToLpFileForms(lpFileForm);
>
> }
>
> editingContext().saveChanges();
> }
> ....
> ....
> }
>
> On Thu, Jul 8, 2010 at 10:38 AM, Ramsey Gurley <[email protected]> wrote:
>
> On Jul 8, 2010, at 9:46 AM, Greg Lappen wrote:
>
> Hi all,
>
> I am running into a bizarre issue with our WebObjects Application. I have
> searched the lists for quite a while, but could not find a case where someone
> had the same problem.
>
> What is even stranger is that our application is deployed on two different
> servers, both with WebObjects 5.4.3 and in one environment the issue occurs,
> and not in the other.
>
> What I see is that calling editingContext.saveChanges() is returning
> immediately in one case, and hanging for 20 seconds in the other case. It's
> not really "hanging" - the CPU is pegged at over 100%, and taking thread
> dumps during that 20 seconds shows something like this:
>
> "WorkerThread3" prio=5 tid=0x000000010296a800 nid=0x1519b2000 runnable
> [0x00000001519af000]
> java.lang.Thread.State: RUNNABLE
> at java.lang.reflect.Array.newInstance(Array.java:52)
> at
> com.webobjects.foundation._NSCollectionPrimitives.copyArray(_NSCollectionPrimitives.java:123)
> at com.webobjects.foundation.NSArray.objectsNoCopy(NSArray.java:356)
> at
> com.webobjects.foundation.NSMutableArray._removeObject(NSMutableArray.java:225)
> at
> com.webobjects.foundation.NSMutableArray.removeObject(NSMutableArray.java:247)
> at
> com.webobjects.foundation.NSMutableArray.removeObjects(NSMutableArray.java:399)
> at
> com.webobjects.foundation.NSMutableArray.removeObjectsInArray(NSMutableArray.java:285)
> at
> com.webobjects.foundation._NSArrayUtilities.arrayExcludingObjectsFromArray(_NSArrayUtilities.java:173)
> at
> com.webobjects.eoaccess.EODatabaseContext.recordChangesInEditingContext(EODatabaseContext.java:5943)
> at
> com.webobjects.eocontrol.EOObjectStoreCoordinator.saveChangesInEditingContext(EOObjectStoreCoordinator.java:373)
> at
> com.webobjects.eocontrol.EOEditingContext.saveChanges(EOEditingContext.java:3192)
> at net.paperfree.lightbeam.model.LPFile.setFileData(LPFile.java:102)
>
> Seems like the EODatabaseContext is doing some housekeeping before executing
> the SQL....here's the Java code in question:
>
> public class LPFile extends _LPFile {
> ....
> ....
> public synchronized void setFileData(NSData fileData) throws IOException {
> // Update forms by deleting existing ones, then adding new ones
> for (int i=lpFileForms().count()-1; i>=0; i--) {
> final LPFileForm lpFileForm = (LPFileForm)
> lpFileForms().objectAtIndex(i);
> this.removeFromLpFileForms(lpFileForm);
> editingContext().deleteObject(lpFileForm);
> }
>
> // Get new form list via SOAP call
> Element docInfoElm = LPServer.threadLocal().exportDocumentInfo(this);
> List formElms = formsElm.getChildren("form");
> for (int i = 0; i < formElms.size(); i++) {
> Element formElm = (Element) formElms.get(i);
>
> You have violated the commandments below. Thou shalt not modify an EO before
> inserting it into an EC.
>
> http://wiki.objectstyle.org/confluence/display/WO/EOF-Using+EOF-The+EOF+Commandments
>
>
> LPFileForm lpFileForm = new LPFileForm();
>
> // extract data from xml, put into lpFileForm
>
> // Setup relationships to lpForm and lpFile
> lpFileForm.setLpForm(lpForm);
> lpFileForm.setLpFormID(lpForm.id());
> lpFileForm.setLpFile(this);
> lpFileForm.setLpFileID(this.fileID());
>
> this.addToLpFileForms(lpFileForm);
> editingContext().insertObject(lpFileForm);
> }
>
> editingContext().saveChanges();
> }
> ....
> ....
> }
>
> Does the above code have anything obviously wrong with it? It's basically
> clearing a one-to-many relationship, then re-populating it. I call
> this.addToLpFileForms() because I want the relationship updated in memory as
> well as in the database.
>
> Any insight would be hugely appreciated.
>
> Thanks,
>
> Greg
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list ([email protected])
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/webobjects-dev/ramsey%40xeotech.com
>
> This email sent to [email protected]
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list ([email protected])
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/webobjects-dev/farrukh.ijaz%40fuegodigitalmedia.com
>
> This email sent to [email protected]
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com
This email sent to [email protected]