Return-Path: X-Original-To: apmail-cayenne-user-archive@www.apache.org Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 384018F5E for ; Fri, 26 Aug 2011 15:37:12 +0000 (UTC) Received: (qmail 54022 invoked by uid 500); 26 Aug 2011 15:37:12 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 53997 invoked by uid 500); 26 Aug 2011 15:37:11 -0000 Mailing-List: contact user-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cayenne.apache.org Delivered-To: mailing list user@cayenne.apache.org Received: (qmail 53989 invoked by uid 99); 26 Aug 2011 15:37:11 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Aug 2011 15:37:11 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [208.78.103.231] (HELO vorsha.objectstyle.org) (208.78.103.231) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 26 Aug 2011 15:37:01 +0000 Received: (qmail 15794 invoked from network); 26 Aug 2011 15:36:39 -0000 Received: from unknown (HELO ?192.168.1.94?) (194.158.197.10) by vorsha.objectstyle.org with SMTP; 26 Aug 2011 15:36:39 -0000 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Apple Message framework v1084) Subject: Re: NullPointerException when ObjectContext.commitChanges() called From: Andrus Adamchik In-Reply-To: Date: Fri, 26 Aug 2011 18:36:38 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: <00660D31-3A10-4AB0-B257-24B2B86D5481@objectstyle.org> References: To: user@cayenne.apache.org X-Mailer: Apple Mail (2.1084) X-Virus-Checked: Checked by ClamAV on apache.org I think the reason is that you haven't mapped and DataNodes (at least = cayenne.xml doesn't have any). DataNode is an abstraction of a DB = connection pool. E.g. see = http://cayenne.apache.org/doc30/tutorial-starting-project.data/base-datano= de.png which is a part of the Cayenne tutorial at = http://cayenne.apache.org/doc30/tutorial-starting-project.html Andrus On Aug 26, 2011, at 6:32 PM, Joel Becker wrote: > Hello. In my app I create an ObjectContext, create some domain = objects, and call commitChanges(), which causes a NullPointerException = with the following stack trace: >=20 > Exception in thread "main" org.apache.cayenne.CayenneRuntimeException: = [v.3.0.1 Sep 06 2010 15:09:38] Commit Exception > at = org.apache.cayenne.access.DataContext.flushToParent(DataContext.java:1134)= > at = org.apache.cayenne.access.DataContext.commitChanges(DataContext.java:1045)= > at net.joelbecker.exercise.App.main(App.java:50) > Caused by: java.lang.NullPointerException > at = org.apache.cayenne.access.DataDomainInsertBucket.createPermIds(DataDomainI= nsertBucket.java:101) > at = org.apache.cayenne.access.DataDomainInsertBucket.appendQueriesInternal(Dat= aDomainInsertBucket.java:76) > at = org.apache.cayenne.access.DataDomainSyncBucket.appendQueries(DataDomainSyn= cBucket.java:79) > at = org.apache.cayenne.access.DataDomainFlushAction.preprocess(DataDomainFlush= Action.java:182) > at = org.apache.cayenne.access.DataDomainFlushAction.flush(DataDomainFlushActio= n.java:134) > at = org.apache.cayenne.access.DataDomain.onSyncFlush(DataDomain.java:824) > at = org.apache.cayenne.access.DataDomain$2.transform(DataDomain.java:791) > at = org.apache.cayenne.access.DataDomain.runInTransaction(DataDomain.java:850)= > at = org.apache.cayenne.access.DataDomain.onSync(DataDomain.java:788) > at = org.apache.cayenne.access.DataContext.flushToParent(DataContext.java:1106)= > ... 2 more >=20 > I created from scratch a data model in Cayenne Modeler, and generated = the java files from there into a maven project which also includes the = cayenne.xml and map files in src/main/resources, and App.java in = src/main/java/. I attached all of my files. I'm using modeller = 3.0.2 and library version 3.0.1. >=20 > I debugged into the Cayenne code for a while and found that the reason = the NPE occurs at DataDomainInsertBucket:101 because node is null = because parent.getDomain().lookupDataNode("Exercise") returns null = because DataDomain.nodesByDataMapName is empty. I traced the map file = loading code for a while but haven't figured out where = nodesByDataMapName is populated and why it is not being populated (my = breakpoint at the first line of DataDomain.addNode() never hits). Has = anyone seen this before, or has an idea why it occurs? >=20 > Thanks. > -Joel >