Hi folks,
This mail is for anyone working against HEAD (ie SNAPSHOTs), rather than
our most recent formal release, and also if using the JDO/DataNucleus
Objectstore.
Jeroen and I are building a substantial app using Wicket/JDO, and we
encountered an issue with lazy loading, logged as ISIS-389 [1]. It turns
out that the "loaded" lifecycle callback method - that Isis uses as its
hook for dependency injection into the entities - is only called when *all*
of the fields/properties in the default fetch group have been loaded; in
other words it is indeterminate.
The consequence of this is that any attempt to invoke an action on the
domain object may result in NPE if it tries to use a not-yet-injected
service or the container.
We have, though, found a solution, but it entails moving up to DN 3.2 (from
DN 3.1) and a configuration change. This impacts the pom.xml and
persistor_datanucleus.properties file.
I've checked in the change to ISIS-389, but if you are running against
HEAD, then you'll also need to update your project also.
1. In the "dom" project's pom.xml, change:
<groupId>org.datanucleus</groupId>
<artifactId>maven-datanucleus-plugin</artifactId>
<version>3.1.1</version>
to:
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-maven-plugin</artifactId>
<version>3.2.0-release</version>
2. Also in this pom, delete the dependency
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-enhancer</artifactId>
... it is no more.
3. If you are using m2e and has configured a
org.eclipse.m2e:lifecycle-mapping plugin entry, then this will need
updating also for datanucleus-maven-plugin.
4. and also, if you are using m2e, you may also have a profile defined:
<profile>
<id>not-m2e</id>
<activation>
<property>
<name>!m2e.version</name>
</property>
</activation>
<dependencies>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-core</artifactId>
<version>(3.0.99, 3.1.99)</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-enhancer</artifactId>
<version>(3.0.99, 3.1.99)</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</profile>
change this to:
<profile>
<id>not-m2e</id>
<activation>
<property>
<name>!m2e.version</name>
</property>
</activation>
<dependencies>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-core</artifactId>
<version>(3.1.99, 3.2.99)</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</profile>
5. in your persistor_datanucleus.properties, change:
isis.persistor.datanucleus.impl.javax.jdo.PersistenceManagerFactoryClass=org.datanucleus.api.jdo.JDOPersistenceManagerFactory
to:
isis.persistor.datanucleus.impl.javax.jdo.PersistenceManagerFactoryClass=org.apache.isis.objectstore.jdo.datanucleus.JDOPersistenceManagerFactoryForIsis
If you don't have this key, then there's nothing to do.
You might also want to upgrade the DataNucleus Eclipse plugin (though I
don't think this is mandatory); latest version is 3.0.4.
That's it, I think. any problems, reply on this thread.
Cheers
Dan
[1] https://issues.apache.org/jira/browse/ISIS-389