Null Pointer Exception - EOAccessDeferredFaultHandler.createFaultForDeferredFault

"Shelli D. Orton" <[email protected]>
Newsgroups gmane.comp.web.webobjects.devel
Message-ID <[email protected]>
Hi,

 

We've recently added some tables to our database and to our EOModel,
PropertyKey, Property and PropertyKeyOption (plist/fspec for each are
included below).  There's a one to many relationship between PropertyKey and
PropertyKeyOption  and also between PropertyKey and Property .  I have a
fetch spec to retreive PropertyKeys that is used in a component.  The
PropertyKeys are fetched but the Property and PropertyKeyOptions don't seem
to be faulted.

 

I get the PropertyKeys with the following method:

 

    public NSArray getPropertyKeys()

    {

            WMLog.log("Fetching keys... " );

            NSArray keys =
PropertyKey.fetchPropertyKeysForEntityName(editingContext(),
propertyEntityName);

            if (keys != null)               

                        log("Fetched keys: " + keys.count());

            else

                        log("Keys are null");

            return keys;

    }

 

I then iterate through the keys and create a sub-component which takes a
PropertyKey binding.  The sub-component's set method looks like:

 

    public void setPropertyKey(PropertyKey key)

    {

            propertyKey = key;

            log("key set to: " + propertyKey.key());

            log("key set to: " + propertyKey);

    }

 

When I hit the second log statement, I get a NullPointerException.  Here's
an excerpt from the log including stack trace:

 

2006-03-10 05:13:12,936 [WorkerThread3] DEBUG log - Fetching keys... 

2006-03-10 05:13:12,952 [WorkerThread3] DEBUG log - Fetched keys: 3

2006-03-10 05:13:12,952 [WorkerThread3] DEBUG log - key set to:
is_provisioned

[2006-03-10 10:13:13 MST] <WorkerThread3>
<com.webobjects.appserver._private.WOComponentRequestHandler>: Exception
occurred while handling request:

java.lang.NullPointerException

[2006-03-10 10:13:13 MST] <WorkerThread3> java.lang.NullPointerException

            at
com.webobjects.eoaccess.EOAccessDeferredFaultHandler.createFaultForDeferredF
ault(EOAccessDeferredFaultHandler.java:42)

            at
com.webobjects.eocontrol.EOCustomObject.willReadRelationship(EOCustomObject.
java:1295)

            at
com.webobjects.eocontrol._EOMutableKnownKeyDictionary$Initializer$_LazyGener
icRecordBinding.valueInObject(_EOMutableKnownKeyDictionary.java:552)

            at
com.webobjects.eocontrol.EOCustomObject.storedValueForKey(EOCustomObject.jav
a:1729)

            at PropertyKey.propertyKeyOptions(PropertyKey.java:101)

            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(NSKe
yValueCoding.java:1160)

            at
com.webobjects.eocontrol.EOCustomObject.valueForKey(EOCustomObject.java:1552
)

            at
com.webobjects.eocontrol.EOCustomObject.eoDescription(EOCustomObject.java:79
3)

            at
com.webobjects.eocontrol.EOCustomObject.toString(EOCustomObject.java:239)

            at java.lang.String.valueOf(Unknown Source)

            at java.lang.StringBuffer.append(Unknown Source)

            at CMProperty.setPropertyKey(CMProperty.java:23)

            at sun.reflect.GeneratedMethodAccessor78.invoke(Unknown Source)

            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
Source)

            at java.lang.reflect.Method.invoke(Unknown Source)

            at
KeyValueCodingProtectedAccessor.setMethodValue(KeyValueCodingProtectedAccess
or.java:65)

            at
com.webobjects.foundation.NSKeyValueCoding$_MethodBinding.setValueInObject(N
SKeyValueCoding.java:1175)

            at
com.webobjects.foundation.NSKeyValueCoding$DefaultImplementation.takeValueFo
rKey(NSKeyValueCoding.java:1293)

            at
com.webobjects.appserver.WOComponent.takeValueForKey(WOComponent.java:1555)

            at
com.webobjects.appserver.WOComponent.pullValuesFromParent(WOComponent.java:5
20)

            at
com.webobjects.appserver._private.WOComponentReference._pushComponentInConte
xt(WOComponentReference.java:93)

            at
com.webobjects.appserver._private.WOComponentReference.appendToResponse(WOCo
mponentReference.java:119)

            at
com.webobjects.appserver._private.WODynamicGroup.appendChildrenToResponse(WO
DynamicGroup.java:121)

            at
com.webobjects.appserver._private.WORepetition.appendToResponse(WORepetition
.java:273)

            at
com.webobjects.appserver._private.WODynamicGroup.appendChildrenToResponse(WO
DynamicGroup.java:121)

            at
com.webobjects.appserver._private.WODynamicGroup.appendToResponse(WODynamicG
roup.java:130)

            at
com.webobjects.appserver.WOComponent.appendToResponse(WOComponent.java:997)

            <snip>

 

As shown in the logs, the exception is blown when the PropertyKey toString
is accessed.  Since the toString hasn't been overwritten, it's trying to
access all of its attributes, inlcuding propertyKeyOptions which blows up.
I am not that familiar with the inner workings of WO faulting.  I changed my
fetch spec to pre-fetch the options, which causes the null pointer exception
to occur earlier, during the fetching of the keys.

 

I have scrutinized the EOModel for something weird that would cause this,
but have come up with nothing.  I removed the new tables from the model and
recreated them, and still the same problem.  If I remove the option
relationship, the null pointer blows up on the property relationship.  I
found a post on the web that seemed somewhat similar to my problem, but it
was related to direct to web, which I am not using.  I'm using WO5.2.  Does
anybody have any insight into this problem?

 

All help appreciated,

Shelli

 

 

 

Property.plist

{

    attributes = (

        {

            allowsNull = Y; 

            columnName = ENTITY_ID; 

            externalType = NUMBER; 

            name = entityId; 

            valueClassName = NSNumber; 

            valueType = l; 

        }, 

        {

            columnName = PROPERTY_ID; 

            externalType = NUMBER; 

            name = propertyId; 

            valueClassName = NSNumber; 

            valueType = l; 

        }, 

        {

            allowsNull = Y; 

            columnName = PROPERTY_KEY_ID; 

            externalType = NUMBER; 

            name = propertyKeyId; 

            valueClassName = NSNumber; 

            valueType = l; 

        }, 

        {

            allowsNull = Y; 

            columnName = VALUE; 

            externalType = VARCHAR2; 

            name = value; 

            valueClassName = NSString; 

            valueType = S; 

            width = 100; 

        }

    ); 

    attributesUsedForLocking = (propertyId, propertyKeyId, entityId, value);


    className = Property; 

    classProperties = (propertyId, propertyKeyId, entityId, value,
propertyKey); 

    externalName = PROPERTY; 

    name = Property; 

    primaryKeyAttributes = (propertyId); 

    relationships = (

        {

            deleteRule = EODeleteRuleNoAction; 

            destination = PropertyKey; 

            isMandatory = Y; 

            isToMany = N; 

            joinSemantic = EOInnerJoin; 

            joins = ({destinationAttribute = propertyKeyId; sourceAttribute
= propertyKeyId; }); 

            name = propertyKey; 

        }

    ); 

}

----------------------------------------------------------------------------
---------------------

PropertyKey.plist

{

    attributes = (

        {

            allowsNull = Y; 

            columnName = DEFAULT_VALUE; 

            externalType = VARCHAR2; 

            name = defaultValue; 

            valueClassName = NSString; 

            valueType = S; 

            width = 100; 

        }, 

        {

            allowsNull = Y; 

            columnName = ENTITY_NAME; 

            externalType = VARCHAR2; 

            name = entityName; 

            valueClassName = NSString; 

            valueType = S; 

            width = 128; 

        }, 

        {

            allowsNull = Y; 

            columnName = KEY; 

            externalType = VARCHAR2; 

            name = key; 

            valueClassName = NSString; 

            valueType = S; 

            width = 25; 

        }, 

        {

            allowsNull = Y; 

            columnName = NAME; 

            externalType = VARCHAR2; 

            name = name; 

            valueClassName = NSString; 

            valueType = S; 

            width = 64; 

        }, 

        {

            columnName = PROPERTY_KEY_ID; 

            externalType = NUMBER; 

            name = propertyKeyId; 

            valueClassName = NSNumber; 

            valueType = l; 

        }, 

        {

            allowsNull = Y; 

            columnName = SORT_ORDER; 

            externalType = NUMBER; 

            name = sortOrder; 

            valueClassName = NSNumber; 

            valueType = l; 

        }, 

        {

            allowsNull = Y; 

            columnName = TYPE; 

            externalType = VARCHAR2; 

            name = type; 

            valueClassName = NSString; 

            valueType = S; 

            width = 25; 

        }

    ); 

    attributesUsedForLocking = (propertyKeyId, key, entityName, type,
defaultValue, name, sortOrder); 

    className = PropertyKey; 

    classProperties = (

        propertyKeyId, 

        key, 

        entityName, 

        type, 

        defaultValue, 

        name, 

        sortOrder, 

        properties, 

        propertyKeyOptions

    ); 

    externalName = PROPERTY_KEY; 

    name = PropertyKey; 

    primaryKeyAttributes = (propertyKeyId); 

    relationships = (

        {

            deleteRule = EODeleteRuleCascade; 

            destination = Property; 

            isToMany = Y; 

            joinSemantic = EOInnerJoin; 

            joins = ({destinationAttribute = propertyKeyId; sourceAttribute
= propertyKeyId; }); 

            name = properties; 

            ownsDestination = Y; 

        }, 

        {

            deleteRule = EODeleteRuleCascade; 

            destination = PropertyKeyOption; 

            isToMany = Y; 

            joinSemantic = EOInnerJoin; 

            joins = ({destinationAttribute = propertyKeyId; sourceAttribute
= propertyKeyId; }); 

            name = propertyKeyOptions; 

            ownsDestination = Y; 

        }

    ); 

}

----------------------------------------------------------------------------
---------------------

PropertyKey.fspec

{

    PropertyKeys = {

        class = EOFetchSpecification; 

        entityName = PropertyKey; 

        fetchLimit = 0; 

        isDeep = YES; 

        qualifier = {

            class = EOKeyValueQualifier; 

            key = entityName; 

            selectorName = "isEqualTo:"; 

            value = {_key = entityName; class = EOQualifierVariable; }; 

        }; 

        refreshesRefetchedObjects = YES; 

        sortOrderings = (

            {class = EOSortOrdering; key = sortOrder; selectorName =
"compareAscending:"; }

        ); 

    }; 

}

 

----------------------------------------------------------------------------
---------------------

PropertyKeyOption.plist

{

    attributes = (

        {

            allowsNull = Y; 

            columnName = NAME; 

            externalType = VARCHAR2; 

            name = name; 

            valueClassName = NSString; 

            valueType = S; 

            width = 25; 

        }, 

        {

            allowsNull = Y; 

            columnName = PROPERTY_KEY_ID; 

            externalType = NUMBER; 

            name = propertyKeyId; 

            valueClassName = NSNumber; 

            valueType = l; 

        }, 

        {

            columnName = PROPERTY_KEY_OPTION_ID; 

            externalType = NUMBER; 

            name = propertyKeyOptionId; 

            valueClassName = NSNumber; 

            valueType = l; 

        }, 

        {

            allowsNull = Y; 

            columnName = SORT_ORDER; 

            externalType = NUMBER; 

            name = sortOrder; 

            valueClassName = NSNumber; 

            valueType = l; 

        }, 

        {

            allowsNull = Y; 

            columnName = VALUE; 

            externalType = VARCHAR2; 

            name = value; 

            valueClassName = NSString; 

            valueType = S; 

            width = 100; 

        }

    ); 

    attributesUsedForLocking = (propertyKeyOptionId, value, name, sortOrder,
propertyKeyId); 

    className = PropertyKeyOption; 

    classProperties = (propertyKeyOptionId, value, name, sortOrder,
propertyKeyId, propertyKey); 

    externalName = PROPERTY_KEY_OPTION; 

    fetchSpecificationDictionary = {}; 

    name = PropertyKeyOption; 

    primaryKeyAttributes = (propertyKeyOptionId); 

    relationships = (

        {

            deleteRule = EODeleteRuleNoAction; 

            destination = PropertyKey; 

            isMandatory = Y; 

            isToMany = N; 

            joinSemantic = EOInnerJoin; 

            joins = ({destinationAttribute = propertyKeyId; sourceAttribute
= propertyKeyId; }); 

            name = propertyKey; 

        }

    ); 

}

_______________________________________________
WebObjects-dev mailing list
[email protected]
http://www.omnigroup.com/mailman/listinfo/webobjects-dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.