Issue Details (XML | Word | Printable)

Key: NUCCORE-1019
Type: Bug Bug
Status: Closed Closed
Resolution: Cannot Reproduce
Priority: Testcase Required Testcase Required
Assignee: Unassigned
Reporter: Chris Colman
Votes: 0
Watchers: 0

If you were logged in you would be able to see more operations.
DataNucleus Core

When using autoStartMechanism=MetaData / Files retrieving collection causes NPE if class not found in metafile

Created: 27/Mar/13 02:48 AM   Updated: 19/Nov/13 10:28 AM   Resolved: 18/Nov/13 05:24 PM
Component/s: None
Affects Version/s: None
Fix Version/s: None

Occurs on both H2 and MySQL

 Description  « Hide
When using the following method to supply metadata:


Assume a portion of your class diagram has:

Class A has many Class B

and B has many subclasses.

with relationship implemented as, for example, an ArrayList.

And also assume that Class B and its subclasses are not included in any of the metadata files listed in autoStartMetaDataFiles,

then calling a.getAllBs() causes an NPE in DN code:

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
at java.lang.reflect.Constructor.newInstance(
at org.datanucleus.util.ClassUtils.newInstance(
at org.datanucleus.state.JDOStateManager.wrapSCOField(
at org.datanucleus.cache.L2CacheRetrieveFieldManager.fetchObjectField(
at org.datanucleus.state.AbstractStateManager.replacingObjectField(

Source code is:

1018 if (ownerTable != null)
1019 {
1020 JavaTypeMapping m = ownerTable.getMemberMapping(mmd);
1021 if (!expectedMappingType.isAssignableFrom(m.getClass()))
1022 {
1023 throw new IncompatibleFieldTypeException(mmd.getFullFieldName(),
1024 type.getName(), mmd.getTypeName());
1025 }
1026 }

which means either expectedMappingType or m is null.

Adding the appropriate metadata file to the list fixes the problem but a more convenient solution would be to display an error message like:

Metadata not found for class: 'com.acme.package4.SomeClassExtendingB'

Andy Jefferson made changes - 27/Mar/13 07:57 AM
Field Original Value New Value
Priority Major [ 3 ] Incomplete [ 6 ]
Andy Jefferson added a comment - 18/Nov/13 05:24 PM
No testcase provided, and not a use case I have, so nothing to do. Clearly if people see this as important to them they could a). create a testcase that people can run, and b). get involved in the project and contribute updates to whatever they are seeing

Andy Jefferson made changes - 18/Nov/13 05:24 PM
Status Open [ 1 ] Resolved [ 5 ]
Resolution Cannot Reproduce [ 5 ]
Andy Jefferson made changes - 19/Nov/13 10:28 AM
Status Resolved [ 5 ] Closed [ 6 ]