Issue Details (XML | Word | Printable)

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

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

Environment:
Windows
Occurs on both H2 and MySQL


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

datanucleus.autoStartMechanism=MetaData
datanucleus.autoStartMetaDataFiles=com/acme/packagename1/package.jdo,\
com/acme/packagename2/package.jdo,\
com/acme/packagename3/package.jdo

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:

java.lang.NullPointerException
at org.datanucleus.store.rdbms.RDBMSStoreManager.assertCompatibleFieldType(RDBMSStoreManager.java:1021)
at org.datanucleus.store.rdbms.RDBMSStoreManager.getBackingStoreForField(RDBMSStoreManager.java:986)
at org.datanucleus.store.types.backed.ArrayList.<init>(ArrayList.java:96)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.datanucleus.util.ClassUtils.newInstance(ClassUtils.java:100)
at org.datanucleus.store.types.SCOUtils.createSCOWrapper(SCOUtils.java:233)
at org.datanucleus.store.types.SCOUtils.newSCOInstance(SCOUtils.java:138)
at org.datanucleus.state.JDOStateManager.wrapSCOField(JDOStateManager.java:2191)
at org.datanucleus.cache.L2CacheRetrieveFieldManager.fetchObjectField(L2CacheRetrieveFieldManager.java:177)
at org.datanucleus.state.AbstractStateManager.replacingObjectField(AbstractStateManager.java:2337)

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 ]