Re: Null pointer in Cayenne 2.0.3 code

From: Alexander Lamb (dev) ("Alexander)
Date: Sun Sep 02 2007 - 05:15:04 EDT

  • Next message: Borut Bolčina: "[C3] logging"

    >

    Andrus,

    It now works (or at least, it goes past the problem I had).
    Indeed, entityResolver was null.

    Initializing correctly the DataContext made it work. Maybe adding an
    Exception in Cayenne warning of a null entity resolver (and telling
    how to initialize the DataContext) could help?

    Well, again, thanks a LOT !!!

    On a side note, we now have an application deployed with Cayenne
    2.0.3 since approximately 2 months using Tapestry 4.1

    We are currently writing another app using Cayenne 2.0.3 and Tapestry
    5. Depending on schedule, we might move to Cayenne 3 in the near future.

    Alexander

    >> But what you are saying is DataContext has a null EntityResolver.
    >
    > Yes, but I guess the first thing to check is whether my assumption
    > about this is true in your code [if(context.getEntityResolver() ==
    > null) { ... }].
    >
    >> This could come from deserializing a DataContext.
    >
    > Potentially, although in most cases it works, but see my last
    > comment below - I think another reason is more likely.
    >
    >> What else could make the DataContext loose the EntityResolver? Is
    >> there one EntityResolver per DataContext or per Entity?
    >
    > There's one shared by all contexts (it belongs to a DataDomain).
    >
    >> The DataContext is simply created doing a new DataContext().
    >
    > That is probably the reason. This constructor creates a DataContext
    > that is not attached to Cayenne stack (as its JavaDoc comment
    > states). I would recommend using a static factory method that
    > properly connects the context:
    >
    > DataContext context = DataContext.createDataContext();
    >
    > Or if you instantiate Cayenne Configuration yourself instead of
    > using the default singleton, check the source of
    > 'createDataContext' and create the instantiation method that uses
    > your own configuration instance.
    >
    > Cheers,
    > Andrus
    >
    >
    >
    >



    This archive was generated by hypermail 2.0.0 : Sun Sep 02 2007 - 05:15:43 EDT