Re: currently saving for so it cannot prepare to save for

"Jerry W. Walker" <[email protected]>
Newsgroups gmane.comp.web.webobjects.devel
Message-ID <[email protected]>
Hi, Chad,

On Jan 19, 2006, at 9:12 AM, Chad Pilkington wrote:

> When you use rawRowsForSQL does it use the object store coordinator.

Yes.

> I am using it to fetch some results from queries?  Is it possible  
> that when I am using rawRowForSQL and someone else tries to save  
> that this error occurs?

That's the most likely scenario for triggering this exception.

You can download a copy of the CountFetcher class that Alex Cone,  
Lenny Marx and I collaborated on at:

      http://wocode.com/cgi-bin/WebObjects/WOCode.woa/2/wa/ 
ShareCodeItem?itemId=429

It shows code that plays with the lower levels of the EOStack and how  
the EOObjectStoreCoordinator should be locked.

Regards,
Jerry



> ----- Original Message -----
> From: Jerry W. Walker
> To: Chad Pilkington
> Cc: [email protected]
> Sent: Thursday, January 19, 2006 8:53 AM
> Subject: Re: currently saving for so it cannot prepare to save for
>
> Hi, Chad,
>
> This looks like a failure to lock the EOObjectStoreCoordinator.  
> Typically, this is done by default in the standard use of the  
> default editing context. The following is from the  
> EOObjectStoreCoordinator JavaDoc documentation for the lock method:
>
> ========================
> This method is used to protect access to the receiver from  
> concurrent operations by multiple threads. EOEditingContexts will  
> indirectly lock their EOObjectStoreCoordinators when necessary.  
> Locking an EOObjectStoreCoordinator will cause the coordinator to  
> lock each registered EOCooperatingObjectStore managed by that  
> coordinator. Applications which make direct use of an  
> EOObjectStoreCoordinator should lock and unlock it as appropriate.  
> Do not confuse this with any methods which work with the database  
> locking mechanism.
> ========================
>
> If you reformat your error message as follows it looks more like a  
> stack trace:
>
> ========================
> IllegalStateException: prepareForSaveWithCoordinator:  
> EODatabaseContext@e9e799 is currently saving for  
> EOEditingContext@aa0933 so it cannot prepare to save for  
> EOEditingContext@c73be3.
>
> EOObjectStoreCoordinator@3d2b3 has sources (EODatabaseContext@e9e799)
> at EODatabaseContext.prepareForSaveWithCoordinator 
> (EODatabaseContext.java:5763)
> at EOObjectStoreCoordinator.saveChangesInEditingContext 
> (EOObjectStoreCoordinator.java:405)
> at EOEditingContext.saveChanges(EOEditingContext.java:3128)
> at Main.actLoginAdmin(Main.java:328)
> at sun.reflect.GeneratedMethodAccessor174.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke 
> (DelegatingMethodAccessorImpl.java:25)
> at reflect.Method.invoke(Method.java:324)
> at KeyValueCodingProtectedAccessor.methodValue 
> (KeyValueCodingProtectedAccessor.java:54)
> at NSKeyValueCoding$_MethodBinding.valueInObject 
> (NSKeyValueCoding.java:1160)
> at NSKeyValueCoding$DefaultImplementation.valueForKey 
> (NSKeyValueCoding.java:1268)
> at WOComponent.valueForKey(WOComponent.java:1544)
> ========================
>
> The error seems to be occurring at Main.actLoginAdmin(Main.java: 
> 328). You might start with that statement to see if any code is  
> directly accessing the EOObjectStoreCoordinator directly without  
> locking.
>
> You also mentioned that you are only using the Session's default  
> editing context and sometimes a child thereof. The child editing  
> contexts should be explicitly locked. Check also to be sure that  
> the code is not creating a peer editing context by leaving out the  
> reference to the default editing context in the constructor message.
>
> HTH.
>
> Regards,
> Jerry
>
> On Jan 18, 2006, at 9:38 PM, Chad Pilkington wrote:
>
>> I have an applicaton where I am getting this error a lot:
>> java.lang.IllegalStateException: prepareForSaveWithCoordinator:  
>> com.webobjects.eoaccess.EODatabaseContext@e9e799 is currently  
>> saving for com.webobjects.eocontrol.EOEditingContext@aa0933 so it  
>> cannot prepare to save for  
>> com.webobjects.eocontrol.EOEditingContext@c73be3.  
>> com.webobjects.eocontrol.EOObjectStoreCoordinator@3d2b3 has  
>> sources (com.webobjects.eoaccess.EODatabaseContext@e9e799) at  
>> com.webobjects.eoaccess.EODatabaseContext.prepareForSaveWithCoordinat 
>> or(EODatabaseContext.java:5763) at  
>> com.webobjects.eocontrol.EOObjectStoreCoordinator.saveChangesInEditin 
>> gContext(EOObjectStoreCoordinator.java:405) at  
>> com.webobjects.eocontrol.EOEditingContext.saveChanges 
>> (EOEditingContext.java:3128) at Main.actLoginAdmin(Main.java:328)  
>> at sun.reflect.GeneratedMethodAccessor174.invoke(Unknown Source)  
>> at sun.reflect.DelegatingMethodAccessorImpl.invoke 
>> (DelegatingMethodAccessorImpl.java:25) at  
>> java.lang.reflect.Method.invoke(Method.java:324) at  
>> KeyValueCodingProtectedAccessor.methodValue 
>> (KeyValueCodingProtectedAccessor.java:54) at  
>> com.webobjects.foundation.NSKeyValueCoding 
>> $_MethodBinding.valueInObject(NSKeyValueCoding.java:1160) at  
>> com.webobjects.foundation.NSKeyValueCoding 
>> $DefaultImplementation.valueForKey(NSKeyValueCoding.java:1268) at  
>> com.webobjects.appserver.WOComponent.valueForKey(WOComponent.java: 
>> 1544)
>>
>> I am having difficulty discovering exactly how this particuar  
>> error is possible using only one EOModel and one Instance of an  
>> application.  I  have never seen this error before in any of my  
>> other applications.  The only real difference that I can see is  
>> that this application has a mySql v 4.0.18 backend where our other  
>> applications have OpenBase backend. As far as I can tell this  
>> error is occuring at a far higher level then the actual database  
>> level.  The application is running on OSX 10.2.8 via monitor.  It  
>> was built in WebObjects 5.2 and is using the  
>> org.gjt.mm.mysql.Driver v 3.0.8.  The application is not using any  
>> special Editing Contexts.  just the session().defaultEditingContext 
>> () and the occational child of that contect new EOEditngContext 
>> (session().defaultEditingContext()).  Does anyone have any idea  
>> what the problem is?
>> _______________________________________________
>> WebObjects-dev mailing list
>> [email protected]
>> http://www.omnigroup.com/mailman/listinfo/webobjects-dev
>
>
> --
> __ Jerry W. Walker,
>    WebObjects Developer/Instructor for High Performance Industrial  
> Strength Internet Enabled Systems
>
>     [email protected]
>     203 278-4085        office
>
>
>
>
>
> _______________________________________________
> WebObjects-dev mailing list
> [email protected]
> http://www.omnigroup.com/mailman/listinfo/webobjects-dev
>


--
__ Jerry W. Walker,
    WebObjects Developer/Instructor for High Performance Industrial  
Strength Internet Enabled Systems

     [email protected]
     203 278-4085        office

_______________________________________________
WebObjects-dev mailing list
[email protected]
http://www.omnigroup.com/mailman/listinfo/webobjects-dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.