Re: Strange _EOCheapCopyMutableArray crash
Re: Strange _EOCheapCopyMutableArray crash
- Subject: Re: Strange _EOCheapCopyMutableArray crash
- From: Ian Joyner <email@hidden>
- Date: Tue, 27 Mar 2007 12:00:06 +1000
Hi Chuck (and others who might see what this problem is),
On 27/03/2007, at 3:09 AM, Chuck Hill wrote:
Hi Ian,
On Mar 25, 2007, at 9:43 PM, Ian Joyner wrote:
I'm getting a crash in the following code:
public boolean is_unassigned () {
// editingContext ().refaultObject (this);
log.info ("is_unassigned " + this.groups ());
boolean result = true;
java.util.Enumeration <Group_Member> e = groups
().objectEnumerator ();
while (result && e.hasMoreElements ()) {
Group_Member gm = e.nextElement ();
if (gm.group ().parent_group () != null && gm.end_date () ==
null) result = false;
}
return result;
}
caused by groups on line 5 being a _EOCheapCopyMutableArray.
Um, no. That just means it is an unfired array fault. See below
for actual cause.
Sorry, did not what to imply that firing a fault was the problem -
merely that is where it is occurring.
The enclosing object for this method was originally created in
another editingContext (being Java client, in another window), so
I suspect something to do with the groups being in another (now
gone) editing context. It does not happen all the time though,
only on the first object created - if I restart the application,
further objects can be added without problem.
It could he a Java Client related bug. It also sounds like that
can happen with incorrect locking of editing contexts or general
EOF abuse. I seem to be saying that a lot lately... :-)
Something has messed up the object graph and / or the local EC
representation.
I suspect some EOF abuse on my part since the main screen was adding
a member, creating the member screen, copying the member and groups
in, and create the join table objects. I changed this to actually
create all these in the member screen editing context, tried a few
other things, but still this occurs. This is after the member screen
does saveChanges and closes, and when the member is displayed in the
list in the main screen. It seems the context information of the
member screen is not getting propagated to the main screen, although
firing the faults should rectify this.
This problem only occurs when inserting the first member in an empty
group – members after that work fine.
Here is the main screen code:
public void create_member (Group in_group) {
// IJ Somehow, I think the copy_into_editing_context is very messy
here. Is there a simpler
// more sure shot way of achieving this?
if (in_group != null) {
if (!in_group.is_archived ()) {
Client_configuration.update_memory_statistics ();
Member_interface_controller member_controller = new
Member_interface_controller ();
EOFrameController.runControllerInNewFrame (member_controller,
"New Member");
member_controller.new_member (top_group, in_group);
} else {
EODialogs.runErrorDialog ("Can't add", "Can't add members to an
archived group.");
}
}
}
and the member screen code:
public void new_member (Group top_group, Group into_group) {
adding = true;
displayGroup ().insert ();
add_to_group ((Group)Service.copy_into_editing_context (top_group,
editingContext ()));
if (into_group != top_group) {
add_to_group ((Group)Service.copy_into_editing_context
(into_group, editingContext ()));
}
}
public void add_to_group (Group to_group) {
Group_Member gm = new Group_Member ();
// This doesn't work either... see Member.is_unassigned problem.
// Group_Member gm = (Group_Member)
EOClassDescription.classDescriptionForEntityName
("Group_Member").createInstanceWithEditingContext (null, null);
editingContext ().insertObject (gm);
gm.addObjectToBothSidesOfRelationshipWithKey (to_group, "group");
gm.addObjectToBothSidesOfRelationshipWithKey ((Member)displayGroup
().selectedObject (), "member");
}
and copy_into_editing_context is:
public static Object copy_into_editing_context (EOGenericRecord
from_object, EOEditingContext into_ec) {
if (from_object == null) log.error ("from_object is null");
if (into_ec == null) log.error ("into_ec is null");
return into_ec.faultForGlobalID (global_id (from_object), into_ec);
}
I've checked the model and the inverse relationships are in place:
Member <-->> Group_Member <<--> Group
A fix that seems to work is the commented out line 'editingContext
().refaultObject (this);', but this seems to me like it is
probably a kludge making up for a problem elsewhere. Anything else
I should be looking out for?
I agree, this is just hiding or recovering from a problem elsewhere.
com.webobjects.eocontrol._EOCheapCopyMutableArray[b7ecdb]
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at
com.webobjects.eodistribution.client.EODistributedObjectStore.objects
ForSourceGlobalID(EODistributedObjectStore.java:338)
That is where the problem happens, it is a NPE not a class cast
exception.
...
Here is the problem:
Exception in thread "AWT-EventQueue-0"
java.lang.IllegalStateException: objectsForSourceGlobalID:
com.webobjects.eodistribution.client.EODistributedObjectStore
com.webobjects.eodistribution.client.EODistributedObjectStore@ae6456
-- for object with global ID _EOIntegralKeyGlobalID[Member
(java.lang.Integer)3] -could not find any snapshot.
at
com.webobjects.eodistribution.client.EODistributedObjectStore.objects
ForSourceGlobalID(EODistributedObjectStore.java:306)
It looks like the snapshot has not been saved or has been
discarded. Is Member #3 a recently created object?
Yes just created.
Chuck
_______________________________________________
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