Re: Validation Exception
Re: Validation Exception
- Subject: Re: Validation Exception
- From: Chuck Hill <email@hidden>
- Date: Mon, 14 Aug 2006 22:06:02 -0700
Hi Marcos,
I am still trying to recover from the flood of messages while I was
at WWDC...
On Aug 10, 2006, at 11:43 AM, Marcos Trejo Munguia wrote:
Hello Chuck,
I was finally able to print the contents of ec.insertedObjects(),
and here is what I've found:
Complete Transaction
Item: {values = {poreceptiondetail = "null"; lot = 421; prefix =
6; supplierlot = <com.webobjects.foundation.NSKeyValueCoding$Null>;
transsign = 1; lineitem = 1; inventorytransheader =
"<InventoryTransHeader 14b1008 <EOTemporaryGlobalID: 0 0 -64 -88 10
3 0 0 7 -26 -51 0 0 0 1 12 -39 19 64 63 103 116 -44 -5>>"; qty =
10000; secondarylot = "1691"; location = "<Location 1852c7f
_EOIntegralKeyGlobalID[Location (java.lang.Integer)4]>"; product =
"<Product aff1e8 _EOIntegralKeyGlobalID[Product (java.lang.Integer)
212]>"; }; this = "<InventoryTransDetail ce3b01
<EOTemporaryGlobalID: 0 0 -64 -88 10 3 0 0 7 -26 -50 0 0 0 1 12 -39
19 64 63 103 116 -44 -5>>"; }
Item: {values = {poreceptiondetail = "null"; lot = 315; prefix =
6; supplierlot = <com.webobjects.foundation.NSKeyValueCoding$Null>;
transsign = 1; lineitem = 2; inventorytransheader =
"<InventoryTransHeader 14b1008 <EOTemporaryGlobalID: 0 0 -64 -88 10
3 0 0 7 -26 -51 0 0 0 1 12 -39 19 64 63 103 116 -44 -5>>"; qty =
7000; secondarylot = "524"; location = "<Location 1852c7f
_EOIntegralKeyGlobalID[Location (java.lang.Integer)4]>"; product =
"<Product 183e712 _EOIntegralKeyGlobalID[Product (java.lang.Integer)
664]>"; }; this = "<InventoryTransDetail 1b8a6af
<EOTemporaryGlobalID: 0 0 -64 -88 10 3 0 0 7 -26 -49 0 0 0 1 12 -39
19 64 63 103 116 -44 -5>>"; }
Item: {values = {poreceptiondetail = "null"; lot = 316; prefix =
6; supplierlot = <com.webobjects.foundation.NSKeyValueCoding$Null>;
transsign = 1; lineitem = 3; inventorytransheader =
"<InventoryTransHeader 14b1008 <EOTemporaryGlobalID: 0 0 -64 -88 10
3 0 0 7 -26 -51 0 0 0 1 12 -39 19 64 63 103 116 -44 -5>>"; qty =
7000; secondarylot = "525"; location = "<Location 1852c7f
_EOIntegralKeyGlobalID[Location (java.lang.Integer)4]>"; product =
"<Product 183e712 _EOIntegralKeyGlobalID[Product (java.lang.Integer)
664]>"; }; this = "<InventoryTransDetail 1c76cab
<EOTemporaryGlobalID: 0 0 -64 -88 10 3 0 0 7 -26 -48 0 0 0 1 12 -39
19 64 63 103 116 -44 -5>>"; }
Item: {values = {poreceptiondetail = "null"; lot = 317; prefix =
6; supplierlot = <com.webobjects.foundation.NSKeyValueCoding$Null>;
transsign = 1; lineitem = 4; inventorytransheader =
"<InventoryTransHeader 14b1008 <EOTemporaryGlobalID: 0 0 -64 -88 10
3 0 0 7 -26 -51 0 0 0 1 12 -39 19 64 63 103 116 -44 -5>>"; qty =
7000; secondarylot = "526"; location = "<Location 1852c7f
_EOIntegralKeyGlobalID[Location (java.lang.Integer)4]>"; product =
"<Product 183e712 _EOIntegralKeyGlobalID[Product (java.lang.Integer)
664]>"; }; this = "<InventoryTransDetail 1af691b
<EOTemporaryGlobalID: 0 0 -64 -88 10 3 0 0 7 -26 -47 0 0 0 1 12 -39
19 64 63 103 116 -44 -5>>"; }
Item: {values = {poreceptiondetail = "null"; lot = 318; prefix =
6; supplierlot = <com.webobjects.foundation.NSKeyValueCoding$Null>;
transsign = 1; lineitem = 5; inventorytransheader =
"<InventoryTransHeader 14b1008 <EOTemporaryGlobalID: 0 0 -64 -88 10
3 0 0 7 -26 -51 0 0 0 1 12 -39 19 64 63 103 116 -44 -5>>"; qty =
7000; secondarylot = "527"; location = "<Location 1852c7f
_EOIntegralKeyGlobalID[Location (java.lang.Integer)4]>"; product =
"<Product 183e712 _EOIntegralKeyGlobalID[Product (java.lang.Integer)
664]>"; }; this = "<InventoryTransDetail 767237
<EOTemporaryGlobalID: 0 0 -64 -88 10 3 0 0 7 -26 -46 0 0 0 1 12 -39
19 64 63 103 116 -44 -5>>"; }
Registered objects where product is null
Item: {values = {poreceptiondetail = "null"; lot = 0; prefix = 0;
supplierlot = <com.webobjects.foundation.NSKeyValueCoding$Null>;
transsign = 1; lineitem = 6; inventorytransheader = "null"; qty =
7000; secondarylot = "528"; location = "null"; product = "null"; };
this = "<InventoryTransDetail 447a24 <EOTemporaryGlobalID: 0 0 -64
-88 10 3 0 0 7 -26 -45 0 0 0 1 12 -39 19 64 63 103 116 -44 -5>>"; }
Interestingly, this is lineitem=6, with 1-5 being in the
insertedObjects(). It appears that something has moved it out of
insertedObjects() and into registeredObject(). As its EOGlobalID is
temporary, it properly ought to be in insertedObjects(). I have seen
things like this happen when an EC processed notifications during
saveChanges() and it was not properly locked. Are you creating
your own editing contexts? If so, are you using Project Wonder or
the MultiECLockManager to manage locking them?
The other possibility is that deleteObject() is getting called on
this InventoryTransDetail. I am not sure if that would result in
what you are seeing or not. Is it possible that your code is
deleting it? Are any other objects getting deleted during this
transaction?
Are you calling revert() on the editing context before starting this
transaction? It could be that some other failed transaction is still
in the editing context (like a failed delete), and this is causing
this to happen.
The first part(Complete Transaction) is the contents of
transaction.inventorytransdetails(), and the second one is the
contents of ec.registeredObjects() where product is null. As you
can see the object where product is null is not part of
transaction.inventorytransdetails(). Another interesting thing is
that all to-one relationships are set to null, I don't have any
idea of how this could have happened. In theory all objects in
transaction. inventorytransdetails() should be in
ec.registeredObjects().
I am not sure. Inserted objects may not appear there until after
saveChanges() has succeeded. I don't recall for certain.
Chuck
On Aug 1, 2006, at 1:36 PM, Chuck Hill wrote:
On Aug 1, 2006, at 11:28 AM, Marcos Trejo Munguia wrote:
Thank you Chuck,
I'll check what I have in the editing context before saving
changes, I'm 100% sure that productSelected.editingContext() == ec.
I just have to wait until the error appears again, because
actually the error only appears in deployment and not all the
time, annoying right? :-)
OK, that is a different problem. That sounds like a concurrency
issue. Are you creating your own editing contexts? Are you
locking them properly? Are you creating additional threads in
your code?
Chuck
On Jul 31, 2006, at 11:35 PM, Chuck Hill wrote:
On Jul 31, 2006, at 4:34 PM, Marcos Trejo Munguia wrote:
Actually the relationship is to-many,
Well, I guess we can discard that theory. :-)
Here is the code that adds details to the header:
public void addItem() {
boolean addItemFailed = false;
if (productSelected == null) {
errors.takeValueForKey("Product is required",
"product");
addItemFailed = true;
}
if (locationSelected == null) {
errors.takeValueForKey("Location is required",
"location");
addItemFailed = true;
}
if (quantity == null) {
errors.takeValueForKey("Qty is required", "quantity");
addItemFailed = true;
} else if (quantity.doubleValue() <= 0) {
errors.takeValueForKey("Qty must be greater than
0", "quantity");
addItemFailed = true;
}
if (!addItemFailed) {
InventoryTransDetail transactionDetail = new
InventoryTransDetail();
ec.insertObject(transactionDetail);
transaction.addObjectToBothSidesOfRelationshipWithKey
(transactionDetail, "inventorytransdetails");
transactionDetail.setTranssign(Constant.ONE);
transactionDetail.setProduct(productSelected);
transactionDetail.setLocation(locationSelected);
transactionDetail.setSecondarylot(secondaryLot);
transactionDetail.setQty(quantity);
}
}
That looks fine.
Here is the code that throws the validation exception, this
validateXXX are in the class InventoryTransDetail:
public Product validateProduct(Product newValue) throws
NSValidation.ValidationException {
if (newValue == null) {
throw new NSValidation.ValidationException("Product
is required");
}
return newValue;
}
Again, that looks fine.
I hope you can help me, I'll really appreciate any help with
this, I have been struggling with this error for 6 months more
less.
It still sounds to me like there is some other
InventoryTransDetail object in that editing context. Have you
tried printing out ec.insertedObjects() just before calling
ec.saveChanges()? Is productSelected.editingContext() == ec?
Chuck
On Jul 31, 2006, at 5:39 PM, Chuck Hill wrote:
You probably have Propagate Primary Key set on this
relationship. If the relationship is to-one and Propagate
Primary Key is set, EOF will automatically create the object
that is the destination of the relationship. You then create
it again in your code, but the object that EOF created is
still in the editing context, will all null values.
Chuck
On Jul 31, 2006, at 2:12 PM, Marcos Trejo Munguia wrote:
Hi list:
I've been having a problem with a validation exception that
must not be happening, here is the stack trace:
com.webobjects.foundation.NSValidation$ValidationException:
Product is required
at InventoryTransDetail.validateProduct
(InventoryTransDetail.java:43)
at sun.reflect.GeneratedMethodAccessor82.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
com.webobjects.foundation._NSReflectionUtilities._invokeMethodOn
Object(_NSReflectionUtilities.java:383)
at com.webobjects.foundation.NSValidation
$_MethodBinding.validateValueOnObject(NSValidation.java:615)
at com.webobjects.foundation.NSValidation
$DefaultImplementation._validateValueForKey(NSValidation.java:
705)
at
com.webobjects.eocontrol.EOCustomObject.validateValueForKey
(EOCustomObject.java:1341)
at com.webobjects.eocontrol.EOCustomObject.validateForSave
(EOCustomObject.java:1411)
at com.webobjects.eocontrol.EOCustomObject.validateForInsert
(EOCustomObject.java:1473)
at com.webobjects.eocontrol.EOEditingContext.validateTable
(EOEditingContext.java:2188)
at
com.webobjects.eocontrol.EOEditingContext.validateChangesForSave
(EOEditingContext.java:2968)
at
com.webobjects.eocontrol.EOEditingContext._prepareForPushChanges
(EOEditingContext.java:3222)
at com.webobjects.eocontrol.EOEditingContext.saveChanges
(EOEditingContext.java:3152)
at ProductionReturn.save(ProductionReturn.java:240)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
Source)
at java.lang.reflect.Method.invoke(Unknown Source)
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:1539)
at com.webobjects.foundation.NSKeyValueCoding
$Utility.valueForKey(NSKeyValueCoding.java:498)
at com.webobjects.foundation.NSKeyValueCodingAdditions
$DefaultImplementation.valueForKeyPath
(NSKeyValueCodingAdditions.java:212)
at com.webobjects.appserver.WOComponent.valueForKeyPath
(WOComponent.java:1600)
at
com.webobjects.appserver._private.WOKeyValueAssociation.valueInC
omponent(WOKeyValueAssociation.java:46)
at
com.webobjects.appserver._private.WOActiveImage.invokeAction
(WOActiveImage.java:255)
at
com.webobjects.appserver._private.WODynamicGroup.invokeChildrenA
ction(WODynamicGroup.java:101)
at
com.webobjects.appserver._private.WODynamicGroup.invokeAction
(WODynamicGroup.java:110)
at
com.webobjects.appserver._private.WOConditional.invokeAction
(WOConditional.java:55)
at
com.webobjects.appserver._private.WODynamicGroup.invokeChildrenA
ction(WODynamicGroup.java:101)
at
com.webobjects.appserver._private.WODynamicGroup.invokeAction
(WODynamicGroup.java:110)
at
com.webobjects.appserver._private.WOConditional.invokeAction
(WOConditional.java:55)
at
com.webobjects.appserver._private.WODynamicGroup.invokeChildrenA
ction(WODynamicGroup.java:101)
at
com.webobjects.appserver._private.WODynamicGroup.invokeAction
(WODynamicGroup.java:110)
at
com.webobjects.appserver._private.WOConditional.invokeAction
(WOConditional.java:55)
at
com.webobjects.appserver._private.WODynamicGroup.invokeChildrenA
ction(WODynamicGroup.java:101)
at
com.webobjects.appserver._private.WODynamicGroup.invokeAction
(WODynamicGroup.java:110)
at com.webobjects.appserver._private.WOForm.invokeAction
(WOForm.java:82)
at
com.webobjects.appserver._private.WODynamicGroup.invokeChildrenA
ction(WODynamicGroup.java:101)
at
com.webobjects.appserver._private.WODynamicGroup.invokeAction
(WODynamicGroup.java:110)
at
com.webobjects.appserver._private.WOConditional.invokeAction
(WOConditional.java:55)
at
com.webobjects.appserver._private.WODynamicGroup.invokeChildrenA
ction(WODynamicGroup.java:101)
at
com.webobjects.appserver._private.WODynamicGroup.invokeAction
(WODynamicGroup.java:110)
at com.webobjects.appserver.WOComponent.invokeAction
(WOComponent.java:945)
at
com.webobjects.appserver._private.WOComponentReference.invokeAct
ion(WOComponentReference.java:104)
at
com.webobjects.appserver._private.WOSwitchComponent.invokeAction
(WOSwitchComponent.java:171)
at
com.webobjects.appserver._private.WOComponentContent.invokeActio
n(WOComponentContent.java:31)
at
com.webobjects.appserver._private.WODynamicGroup.invokeChildrenA
ction(WODynamicGroup.java:101)
at
com.webobjects.appserver._private.WOGenericContainer.invokeActio
n(WOGenericContainer.java:23)
at
com.webobjects.appserver._private.WODynamicGroup.invokeChildrenA
ction(WODynamicGroup.java:101)
at
com.webobjects.appserver._private.WOGenericContainer.invokeActio
n(WOGenericContainer.java:23)
at
com.webobjects.appserver._private.WODynamicGroup.invokeChildrenA
ction(WODynamicGroup.java:101)
at
com.webobjects.appserver._private.WODynamicGroup.invokeAction
(WODynamicGroup.java:110)
at com.webobjects.appserver.WOComponent.invokeAction
(WOComponent.java:945)
at
com.webobjects.appserver._private.WOComponentReference.invokeAct
ion(WOComponentReference.java:104)
at
com.webobjects.appserver._private.WODynamicGroup.invokeChildrenA
ction(WODynamicGroup.java:101)
at
com.webobjects.appserver._private.WODynamicGroup.invokeAction
(WODynamicGroup.java:110)
at com.webobjects.appserver.WOComponent.invokeAction
(WOComponent.java:945)
at com.webobjects.appserver.WOSession.invokeAction
(WOSession.java:1166)
at com.webobjects.appserver.WOApplication.invokeAction
(WOApplication.java:1375)
at
com.webobjects.appserver._private.WOComponentRequestHandler._dis
patchWithPreparedPage(WOComponentRequestHandler.java:196)
at
com.webobjects.appserver._private.WOComponentRequestHandler._dis
patchWithPreparedSession(WOComponentRequestHandler.java:287)
at
com.webobjects.appserver._private.WOComponentRequestHandler._dis
patchWithPreparedApplication(WOComponentRequestHandler.java:322)
at
com.webobjects.appserver._private.WOComponentRequestHandler._han
dleRequest(WOComponentRequestHandler.java:358)
at
com.webobjects.appserver._private.WOComponentRequestHandler.hand
leRequest(WOComponentRequestHandler.java:432)
at com.webobjects.appserver.WOApplication.dispatchRequest
(WOApplication.java:1306)
at com.webobjects.appserver._private.WOWorkerThread.runOnce
(WOWorkerThread.java:173)
at com.webobjects.appserver._private.WOWorkerThread.run
(WOWorkerThread.java:254)
at java.lang.Thread.run(Unknown Source)
I'm using two tables(master-detail), the master is inserted
in the EC when the component is loaded, then you can add
details, the details are only created and inserted in the EC
if the variables holding the values pass some validations
(same validations are implemented in validateXXX methods in
EO class), one of the validations is the one that is being
thrown in saveChanges(). I've no idea of what I'm doing
wrong. If you need a copy of the code and the component
please let me now. I'll appreciate any help.
Thanks in advanced!
--
Coming in late 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
--
Coming sometime... - 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
--
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