cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joel Becker <joelbeck...@gmail.com>
Subject NullPointerException when ObjectContext.commitChanges() called
Date Fri, 26 Aug 2011 15:32:04 GMT
Hello. In my app I create an ObjectContext, create some domain objects, and
call commitChanges(), which causes a NullPointerException with the following
stack trace:

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(DataDomainInsertBucket.java:101)
        at
org.apache.cayenne.access.DataDomainInsertBucket.appendQueriesInternal(DataDomainInsertBucket.java:76)
        at
org.apache.cayenne.access.DataDomainSyncBucket.appendQueries(DataDomainSyncBucket.java:79)
        at
org.apache.cayenne.access.DataDomainFlushAction.preprocess(DataDomainFlushAction.java:182)
        at
org.apache.cayenne.access.DataDomainFlushAction.flush(DataDomainFlushAction.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

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/<package>. I attached all of my files. I'm using modeller
3.0.2 and library version 3.0.1.

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?

Thanks.
-Joel

Mime
View raw message