Re: objectFromDataRow NPE

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Fri Oct 08 2010 - 12:37:28 UTC

  • Next message: Steve Springett: "Re: JGroups Configuration Questions"

    I confirmed - this is a bug with a nested context. Just opened a Jira:

    https://issues.apache.org/jira/browse/CAY-1489

    We'll work on fixing it.

    Andrus

    On Oct 7, 2010, at 7:01 PM, Jeff Rorison wrote:

    > Andrus Adamchik <andrus <at> objectstyle.org> writes:
    >
    >>
    >> Hi Jeff,
    >>
    >> From the lines in the stack trace, looks like
    > context.getObjectStore().getDataRowCache() returns
    >> null, causing an NPE downstream. Now wondering why that can happen... Are you
    >> serializaing/deserializaing your DataContext?
    >>
    >> Andrus
    >>
    >> On Oct 6, 2010, at 9:04 PM, Rorison, Jeff wrote:
    >>
    >>> I am using 3.0 (final) and am having some issues using
    >>> context.createFromDataRow(...)
    >>>
    >>> ObjectResolver is throwing an NPE on what looks like updating snapshots.
    >>> Code:
    >>>
    >>> SQLTemplate template = .....
    >>> template.setFetchingDataRows(true);
    >>> ...
    >>> List res = this.dataContext.performQuery(template);
    >>> Subject sub = (Subject)context.objectFromDataRow(Subject.class,
    >>> (DataRow)res.get(0), true);
    >>>
    >>> Err:
    >>> java.lang.NullPointerException at
    >>> org.apache.cayenne.access.ObjectResolver.objectsFromDataRows(ObjectResol
    >>> ver.java:117)
    >>> at
    >>> org.apache.cayenne.access.ObjectResolver.synchronizedObjectsFromDataRows
    >>> (ObjectResolver.java:94)
    >>> at
    >>> org.apache.cayenne.access.DataContext.objectsFromDataRows(DataContext.ja
    >>> va:597)
    >>> at
    >>> org.apache.cayenne.access.DataContext.objectFromDataRow(DataContext.java
    >>> :646)
    >>> ...........
    >>>
    >>> What, if anything am I doing incorrectly here? I have tried changing the
    >>> refresh, and most of the other API calls with no success?
    >>>
    >>> Has this changed any in 3.0, as I see a few differences between the API
    >>> and the docs?
    >>
    >
    > Andrus,
    >
    > We are running in the Felix OSGi container and are using a Java Proxy object
    > (ObjectContext) to provide the context from a service, no
    > serialization/deserialization.
    >
    > Since the proxy object disallows anything except the interface even a cast to
    > DataContext is disallowed. In most cases the ObjectContext is all we want to
    > provide, but in a few we need a DataContext to perform a little more magic.
    >
    > So, from the original we create a child ObjectContext which we can cast to
    > DataContext so we can do some Cayenne magic.
    >
    > This is where the errors came in to play with ...objectFromDataRow().
    >
    > cheers,
    > jeff
    >
    >
    >
    >



    This archive was generated by hypermail 2.0.0 : Fri Oct 08 2010 - 12:38:01 UTC