Recently updated to 2.0.x nightly build 2010/04/18
I've started seeing an intermittent exception that I've never seen before. It happens at application start up when DataNucleus is initializing:
Caused by: java.lang.NullPointerException
The problem is intermittent so it's impossible to reproduce in a reliable way with a test case.
The current workaround, while frustrating, eventually gets the app started up:
Remove the application from the container
Install the application
Just removing app and reinstalling it will get it working eventually - it can take a number of cycles of the above steps. In other words, the metadata remains exactly the same so I would think that the problem is not caused by invalid metadata.
I've been looking through the source code to try and find an explanation to this. Looking at the line on which it has occurred (marked with >>>>> below) it appears as though pcSuperclassMetaData has not been initialized during some app start ups but not others. There may be some affect where the 'order of class processing' that can trigger this (eg., iterating through a HashSet collection where ordering is largely non deterministic).
I never saw this until recently when I changed the class model and introduced what might be called an 'indirect self referential relationship' to the design:
(where ^ means lower class extends class above it in the ASCII diagram)
D --------> N
The -----> represents the new relationship to the new class 'N' which shares a common base class in A and which appears to have triggered this intermittent NPE. Perhaps the variance in 'NPE thrown or works ok' is based on whether class D gets processed before or after class N.
Possibly we could be deep in the nested processing of the class D branch of the hierarchy when we experience class N which has a different branch but the same, potentially partially processed superclass at the root of the same hierarchy.
* Using datastore identity
* class A uses new table inheritance strategy
* all derived classes use 'superclass table' inheritance strategy
Relevant source code:
* Inherit the identity definition from super classes.
* @throws InvalidMetaDataException if the MetaData of this class conflicts with super classes definition
protected void inheritIdentity()
if (objectidClass != null)
// Make sure the objectid-class is fully-qualified (may have been specified in simple form)
this.objectidClass = ClassUtils.createFullClassName(((PackageMetaData)parent).name, objectidClass);
// Check that the class can be loaded, and is a true superclass
if (persistenceCapableSuperclass != null)
// Class has superclass, yet has objectid-class defined! ops, this might result in user errors
if (objectidClass != null)
>>>>> String superObjectIdClass = pcSuperclassMetaData.getObjectidClass();
if (superObjectIdClass == null || !objectidClass.equals(superObjectIdClass))
throw new InvalidMetaDataException(LOCALISER, "044085", name, persistenceCapableSuperclass);
// by default users should only specify the object-id class in the root persistent class
NucleusLogger.METADATA.warn(LOCALISER.msg("044086", name, persistenceCapableSuperclass));
// get the objectid class from superclass
this.objectidClass = pcSuperclassMetaData.getObjectidClass();
if (this.identityType == null)
this.identityType = pcSuperclassMetaData.getIdentityType();
// Superclass identityType must be the same as this classes identityType
// We can't change the identity type from what was specified in the base class
throw new InvalidMetaDataException(LOCALISER, "044093", fullName);