• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Object not registered in any editingContext?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Object not registered in any editingContext?


  • Subject: Re: Object not registered in any editingContext?
  • From: Ian Joyner <email@hidden>
  • Date: Tue, 28 Mar 2006 17:00:44 +1100

Thanks Chuck, I should have thought of that since every other enumeration type I have handled that way, but this was code left over from about six months ago, which had always seemed to be working. Doesn't seem to be much overhead in the refetch since it must be filtering in memory anyway.

Ian

On 28/03/2006, at 3:19 PM, Chuck Hill wrote:


On Mar 27, 2006, at 7:59 PM, Ian Joyner wrote:

Fixed it! The problem is a small optimization on the server side, trying to load something only once and storing in a static variable - NOT A GOOD IDEA. Normally, this runs just fine, especially in the development environment, where the server is restarted every test. However, when started up in Java monitor, the server sticks around for the next client. Unfortunately, the editing context of the original session and of the shared object was gone. Here is the offending (server-side) code:

static EOGenericRecord pt = null;

private EOGenericRecord person_person_type (EOEditingContext ec) {
// Need to fetch person type reference from ENUMERATION table.
// Only need to fetch reference once in constructor.
// Use EOFetch spec in EOModeller.

if (pt == null) {
NSArray result = ec.objectsWithFetchSpecification (EOFetchSpecification.fetchSpecificationNamed ("person_key_fetch", "Person_type"));
pt = (EOGenericRecord)result.objectAtIndex (0);
System.out.println ("person type loaded "+pt);
}

return pt;
}


The EOF "correct" way to accomplish this is through using EOGlobalID:

static EOGlobalID ptID = null;

private EOGenericRecord person_person_type (EOEditingContext ec) {
// Need to fetch person type reference from ENUMERATION table.
// Only need to fetch reference once in constructor.
// Use EOFetch spec in EOModeller.

if (ptID == null) {
NSArray result = ec.objectsWithFetchSpecification (EOFetchSpecification.fetchSpecificationNamed ("person_key_fetch", "Person_type"));
EOGenericRecord pt = (EOGenericRecord)result.objectAtIndex (0);
ptID = ec.globalIDForObject(pt);
System.out.println ("person type loaded "+pt);
}

return (EOGenericRecord) ec.faultForGlobalID(ptID);
}


This will refetch only if the snapshot for the object has been discarded.

Chuck


and the fixed code to reload every time, which causes an SQL lookup the first time only anyway:

private EOGenericRecord person_person_type (EOEditingContext ec) {
// Fetch person type reference from ENUMERATION table.

NSArray result = ec.objectsWithFetchSpecification (EOFetchSpecification.fetchSpecificationNamed ("person_key_fetch", "Person_type"));
return (EOGenericRecord)result.objectAtIndex (0);
}



Ian

On 28/03/2006, at 11:50 AM, Chuck Hill wrote:

Hi Ian,

On Mar 27, 2006, at 4:40 PM, Ian Joyner wrote:

Thanks for the reply Chuck. I don't think there is a problem with the Person save code, because it also fails on the Member save code (although member is a subclass of person, the controllers are different and the Member controller does not post a notification).

However, I just found something very curious – the problem is not so intermittent. The first time the client-side app runs, a save of an inserted person or member succeeds. If I restart the server in Java Monitor and run the app, records are successfully saved.

However, if I run the app a second time against the same invocation of the server in Java Monitor, the problem occurs, so as you say it looks like there is a leftover EC from somewhere – but from another session?

This would also explain why this never failed when run from Xcode because it creates a new server invocation every time.

Is there anyway an old session might not be cleaned up OK?

Yes, rather easily as it turns out. If you have overridden sleep () or terminate(), ensure that an exception can never be raised.

Chuck



On 28/03/2006, at 11:22 AM, Chuck Hill wrote:

Hi Ian,

On Mar 27, 2006, at 2:41 PM, Ian Joyner wrote:

(Sorry if this is a repost, but it has not turned up in my inbox from last night.)

The list has been a bit unstable the last few days. I was getting bounces at one point that said Webobjects- email@hidden was an unknown mailbox.


I'm intermittently getting the error:

"Cannot obtain globalId for an object which is not registered in any editingContext"

I see quite a few have run into this one over the years and have read all those posts. I'm using Java client, so the error is happening on the server and being reported back to the client.

For me, this does not happen when I build and run the project from Xcode and if I build deployment and run the app, it only happens 50% of the time. Here is the output I am getting from inserting a simple Person object:

[2006-03-27 16:25:13 EST] <AWT-EventQueue-0> CronusIII.client.Person_interface_controller save editing context com.webobjects.eocontrol.EOEditingContext@a88c32

[2006-03-27 16:25:13 EST] <AWT-EventQueue-0> CronusIII.client.Person_interface_controller save inserted ({values = {gender = "<com.webobjects.eocontrol.EOGenericRecord 1a30e7 _EOIntegralKeyGlobalID[Gender (java.lang.Integer)6]>"; skills = (); date_of_birth = <com.webobjects.foundation.NSKeyValueCoding$Null>; termination_date = <com.webobjects.foundation.NSKeyValueCoding $Null>; creation_date = 2006-03-27 06:25:00 Etc/GMT; alias = <com.webobjects.foundation.NSKeyValueCoding$Null>; contacts = (); first_name = "Aadf"; title = "<com.webobjects.eocontrol.EOGenericRecord 809883 _EOIntegralKeyGlobalID[Title (java.lang.Integer)1]>"; surname = "Aadf"; middle_names = <com.webobjects.foundation.NSKeyValueCoding$Null>; notes = (); addresses = (); person_type = "null"; unique_id = <com.webobjects.foundation.NSKeyValueCoding$Null>; custom_data = (); telephones = (); attachments = (); modification_date = 2006-03-27 06:25:00 Etc/GMT; is_a_doctor = "F"; is_a_manager = "F"; images = (); type = "P"; email_addresses = (); }; this = "<com.sportstec.generic.client.Person c6395b <EOTemporaryGlobalID: 0 0 -64 -88 0 7 1 0 7 -47 1 0 0 0 1 10 58 96 115 -91 -54 29 -68 -51>>"; })

[2006-03-27 16:25:13 EST] <AWT-EventQueue-0> CronusIII.client.Person_interface_controller save updated ()
[2006-03-27 16:25:13 EST] <AWT-EventQueue-0> CronusIII.client.Person_interface_controller save deleted ()


[2006-03-27 16:25:13 EST] <AWT-EventQueue-0> CronusIII.client.Person_interface_controller Cannot null Server exception: Cannot obtain globalId for an object which is not registered in any editingContext, object: <com.webobjects.eocontrol.EOGenericRecord 88d364 (EOEditingContext$_EOInvalidFaultHandler aa711)>, databaseContext: com.webobjects.eoaccess.EODatabaseContext@fceb09, object's editingContext: null, databaseContext's active editingContext: com.webobjects.eocontrol.EOEditingContext@989e7c

That looks like something is messaging an EO that was in an editing context which has been finalized.


Which shows the current ec, its inserted object and no deleted or updated objects. The ec of the bad object is indeed null (which is different to most posts). And I'm not using nested contexts. The offending object is an EOGenericRecord, which means it must be either the persons title (mr, mrs, etc) or gender (male, female), however, its address does not match those fields in the person record. The offending EOGenericRecord also has an ec of null.

It wouldn't, it is from a different EC. It is also possible that is it not really generic record, but rather that EOF has lost track of what it used to be.



--
Coming in 2006 - an introduction to web applications using WebObjects and Xcode http://www.global-village.net/wointro


Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems. http://www.global-village.net/products/ practical_webobjects






_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Object not registered in any editingContext? (From: Ian Joyner <email@hidden>)
 >Re: Object not registered in any editingContext? (From: Chuck Hill <email@hidden>)
 >Re: Object not registered in any editingContext? (From: Ian Joyner <email@hidden>)
 >Re: Object not registered in any editingContext? (From: Chuck Hill <email@hidden>)
 >Re: Object not registered in any editingContext? (From: Ian Joyner <email@hidden>)
 >Re: Object not registered in any editingContext? (From: Chuck Hill <email@hidden>)

  • Prev by Date: Re: New Web Components failing to compile?
  • Next by Date: Re: Customizing the EOSortOrdering
  • Previous by thread: Re: Object not registered in any editingContext?
  • Next by thread: wildcard search problem
  • Index(es):
    • Date
    • Thread