IllegalStateException: initializeObject: No snapshot for gid _EOIntegralKeyGlobalID

Lenny Marks <[email protected]> Tue, 19 Aug 2003 00:11:46 -0400 (EDT)
Newsgroups gmane.comp.web.webobjects.eof
Message-ID <Pine.GSO.4.44.0308181338250.1212-100000@kirk>
Actually I am deploying within a tomcat servlet container and I had been
not been using the session().defaultEditingContext(). When I tried using
that, I received a different exception included below. I finally was able
to solve the problem. It turned out to be in the way I was getting my
EODatabaseContext instance on which to call batchFetchRelationship(). I
had been using the following code:

   EOModelGroup mgroup = EOModelGroup.defaultGroup();
   EOModel model = mgroup.modelNamed("manuscripts");
   EODatabaseContext dbContext =
	EODatabaseContext.registeredDatabaseContextForModel(model, ec);

This code did not gaurantee the same database context each time it was
executed. Apparently,(if I understand it correctly) the initializeObject
in EOEditingContext forwards to its parent EOObjectStoreCoordinator which
uses objectStoreForGlobalID to find the EOCooperatingObjectStore to
forward to. It looks like objectStoreForGlobalID did return an instance of
EODatabaseContext, but not the same one that the snapshots had been
recorded in. The corrected code looks like the following:

    EOObjectStoreCoordinator osc = (EOObjectStoreCoordinator)
    	ec.rootObjectStore();
    EODatabaseContext dbContext = (EODatabaseContext)
            osc.objectStoreForObject(this);

    EOEntity correspondenceEntity =
            EOUtilities.entityNamed(ec, "CorrespondenceEvent");

    EORelationship corrRelationship =
            correspondenceEntity.relationshipNamed("correspondence");

     dbContext.batchFetchRelationship
            (corrRelationship, correspondenceEvents, ec);

Exception was:

ava.lang.IllegalStateException: initializeObject: No snapshot for gid
_EOIntegralKeyGlobalID[UserAction (java.lang.Integer)433762]
         at
com.webobjects.eoaccess.EODatabaseContext.initializeObject(EODatabaseContext.java:3705)
         at
com.webobjects.eocontrol.EOObjectStoreCoordinator.initializeObject(EOObjectStoreCoordinator.java:642)
         at
com.webobjects.eocontrol.EOEditingContext.initializeObject(EOEditingContext.java:3707)
         at
com.webobjects.eoaccess.EODatabaseChannel$_EODatabaseChannelFetchResult.initializeObjects(EODatabaseChannel.java:479)
         at
com.webobjects.eoaccess.EODatabaseContext._objectsWithFetchSpecificationEditingContext(EODatabaseContext.java:3214)
         at
com.webobjects.eoaccess.EODatabaseContext.objectsWithFetchSpecification(EODatabaseContext.java:3320)
         at
com.webobjects.eoaccess.EODatabaseContext._batchFetchRelationshipForSourceObjectsEditingContext(EODatabaseContext.java:3908)
         at
com.webobjects.eoaccess.EODatabaseContext.batchFetchRelationship(EODatabaseContext.java:3962)
         at
org.aps.webproeof.manuscript.Manuscript.batchFetchManuscriptEvents(Manuscript.java:145)
.......

On Sun, 17 Aug 2003, Lenny Marks wrote:

>
> I have a direct action to render all information for a specified
> 'Manuscript' in our database. The rendering of this page traces deep into
> the manuscript's relationships and was slow so I was attempting to use
> EODatabaseContext.batchFetchRelationship to limit the hits to the
> database. I added a method batchFetchManuscriptEvents(the root of the deep
> relationships) to my Manuscript EOEnterpriseObject class. I was hoping
> that the application could call this in anticipation of its particular
> display needs. The method would batchFetch all the relationships so that
> by the time the WOComponent was generating its response, all the
> relationships would have already been faulted. This actually worked, but
> only the first time the method is invoked on a Manuscript instance within
> a single EOF stack. The first time I access the direct action for a
> manuscript, it works, but if I hit reload I get the exception below.
>
> Any clues would be greatly appreciated!
>
> -Lenny Marks
>
> <ManView>[2003-08-17 07:49:16 EDT] <Thread-6>
> java.lang.NullPointerException
>         at
> com.webobjects.eocontrol._EOMutableKnownKeyDictionary.<init>(_EOMutableKnownKeyDictionary.java:90)
>         at
> com.webobjects.eoaccess.EORelationship._foreignKeyForSourceRow(EORelationship.java:1094)
>         at
> com.webobjects.eoaccess.EODatabaseContext._followToManyRelationshipWithFetchSpecification(EODatabaseContext.java:2656)
>         at
> com.webobjects.eoaccess.EODatabaseContext._followFetchSpecification(EODatabaseContext.java:2781)
>         at
> com.webobjects.eoaccess.EODatabaseContext._batchFetchRelationshipForSourceObjectsEditingContext(EODatabaseContext.java:3878)
>         at
> com.webobjects.eoaccess.EODatabaseContext.batchFetchRelationship(EODatabaseContext.java:3962)
>         at
> org.aps.webproeof.manuscript.Manuscript.batchFetchRecipients(Manuscript.java:266)
>         at
> org.aps.webproeof.manuscript.Manuscript.batchFetchManuscriptEvents(Manuscript.java:167)
>         at
> org.aps.webprowo.view.ManuscriptView.<init>(ManuscriptView.java:43)
>         at
> org.aps.webprowo.view.ManuscriptView.findByAccode(ManuscriptView.java:62)
>         at DirectAction.findByAccodeAction(Unknown Source)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>
>
> code ex.
>
> /** batch fetch CorrespondenceVersions for correspondences. */
> private void
> batchFetchCorrespondenceVersions(EOModel model,
>                                  EODatabaseContext dbContext,
>                                  NSArray correspondences)
> {
>
>         EOEditingContext ec = editingContext();
>
>         if(correspondences.count() < 1) return;
>
>         LOGGER.debug("batch fetching CorrespondenceVersions");
>
>         Correspondence corr =
> (Correspondence)correspondences.objectAtIndex(0);
>
>         EOEntity corrEntity = model.entityForObject(corr);
>
>         EORelationship versionsRelationship =
> corrEntity.relationshipNamed("versions");
>
>         dbContext.batchFetchRelationship(versionsRelationship,
> correspondences, ec);
>
>     }
>
> _______________________________________________
> EOF mailing list
> [email protected]
> http://www.omnigroup.com/mailman/listinfo/eof
>