cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <>
Subject Re: NullPointerException when ObjectContext.commitChanges() called
Date Fri, 26 Aug 2011 15:36:38 GMT
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

which is a part of the Cayenne tutorial at


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:
> 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(
>         at org.apache.cayenne.access.DataContext.commitChanges(
>         at net.joelbecker.exercise.App.main(
> Caused by: java.lang.NullPointerException
>         at org.apache.cayenne.access.DataDomainInsertBucket.createPermIds(
>         at org.apache.cayenne.access.DataDomainInsertBucket.appendQueriesInternal(
>         at org.apache.cayenne.access.DataDomainSyncBucket.appendQueries(
>         at org.apache.cayenne.access.DataDomainFlushAction.preprocess(
>         at org.apache.cayenne.access.DataDomainFlushAction.flush(
>         at org.apache.cayenne.access.DataDomain.onSyncFlush(
>         at org.apache.cayenne.access.DataDomain$2.transform(
>         at org.apache.cayenne.access.DataDomain.runInTransaction(
>         at org.apache.cayenne.access.DataDomain.onSync(
>         at org.apache.cayenne.access.DataContext.flushToParent(
>         ... 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 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
> <cayenne.xml><>

View raw message