RE: More Detail: NullPointerException in call to DataContext.crea teDataContext()

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Wed Oct 13 2004 - 09:35:11 EDT

  • Next message: Mikaël Cluseau: "Single table inheritance"

    > I'm using Cayenne 1.1B.

    Hmm, still can't find a version of the source that matches the stack trace...

    The log clearly indicates that Cayenne is started and a single domain
    named "Reconciliation" is loaded, which is good.. But the NPE means that
    Cayenne Configuration object that you access has no domains configured...
    So smehow it gets reset.. You may need to debug this some more...

    1. Check that your web.xml file is configured correctly per one of the web
    app deployment strategies described in the docs -
    http://objectstyle.org/cayenne/userguide/deploy/web-application.html (I
    guess WebApplicationListener is the most easy to use one)

    2. Check that that you don't have any explicit Cayenne initialization code
    that may have been copied from a command line app that is initialized
    differently. Scan your app code for any explicit references to Cayenne
    "Configuration" class.

    3. In the web application you usually obtain DataContext from the session
    (though this may vary depending on your case), so instead of "DataContext
    context = DataContext.createDataContext();" you can follow the advise
    given here:
    http://objectstyle.org/cayenne/userguide/deploy/webapplicationlistener.html

    4. Finally you can try debugging the code... E.g. put some log statements
    before the exception line:

    System.out.println("Shared config: " +
    Configuration.getSharedConfiguration());
    System.out.println("Domains: " +
    Configuration.getSharedConfiguration().getDomains());

    DataContext context = DataContext.createDataContext();

    Andrus



    This archive was generated by hypermail 2.0.0 : Wed Oct 13 2004 - 09:35:13 EDT