Re: NullPointerException on non-null attribute
Re: NullPointerException on non-null attribute
- Subject: Re: NullPointerException on non-null attribute
- From: Chuck Hill <email@hidden>
- Date: Wed, 14 Nov 2012 12:41:12 -0800
On 2012-11-14, at 11:49 AM, Maik Musall wrote:
> Am 14.11.2012 um 17:57 schrieb Jesse Tayler <email@hidden>:
>> you got some backtrace on that funky action?
>
> Happens also when a method using that attribute is directly invoked by a wod binding, in a component using autolocking.
Any chance something in your bindings is setting these to null? I've seen that happen, especially if you are doing manual sync.
> Am 14.11.2012 um 18:21 schrieb Chuck Hill <email@hidden>:
>> Also the EOModel checks are only enforced when saveChanges() runs. So it is possible that a bug in your code is setting these to null before you try to use them.
>
> Like I said, happens on *fetched* EOs, not on newly created ones. And as the database has a NOT NULL constraint on the column, I don't see how that attribute can end up being null in the fetched EO, except through a bug in EOF.
Just because it was not null when you fetched it, does not mean it is still not null when you try to use it. :-) Something could have happened in-between. In fact, I think that something MUST have happened. If this is at all reproducible, you can just throw a runtime exception in the set... method if the value is null. That should give you the stack track to track it down.
Null relationships could mean that you are working with an EO that has been deleted. That would not explain null attributes.
Chuck
>
>
>> On 2012-11-14, at 9:16 AM, Ramsey Gurley wrote:
>>> I have seen that in apps that violate the commandments:
>>>
>>> http://wiki.wocommunity.org/pages/viewpage.action?pageId=1050329
>
> I have done my best to follow those, although it's a large application so I can't rule out anything. Going through them just now, however I spotted two awakeFromInsertion() that didn't call super, although not in the classes I experienced those nasty NPE in.
>
>
>>> If relationships are going missing and you are using nested ECs you may want to try
>>>
>>> ec.setRetainsRegisteredObjects(true)
>>>
>>> There's a known bug where EOs can be GCed which can result in nulls coming from required relationships. Nobody has managed to fix it in wonder yet.
>
> I know, I already have that set in every editingcontext, and it eliminated a whole bunch of exceptions I frequently got before.
>
>
> Maik
>
--
Chuck Hill Senior Consultant / VP Development
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/gvc/practical_webobjects
Global Village Consulting ranks 13th in 2012 in BIV's Top 100 Fastest Growing Companies in B.C!
Global Village Consulting ranks 76th in 24th annual PROFIT 200 ranking of Canada’s Fastest-Growing Companies by PROFIT Magazine!
_______________________________________________
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