DataNucleus JIRA is now in read-only mode. Raise any new issues in GitHub against the plugin that it applies to. DataNucleus JIRA will remain for the foreseeable future but will eventually be discontinued
Issue Details (XML | Word | Printable)

Key: NUCNEOFORJ-19
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Jim White
Votes: 0
Watchers: 0
Operations

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

NPE in tutorial using JDO

Created: 01/Aug/12 08:47 AM   Updated: 02/Aug/12 03:08 PM   Resolved: 01/Aug/12 09:25 AM
Component/s: Persistence
Affects Version/s: 3.1.0.m1
Fix Version/s: 3.1.0.m2

File Attachments: 1. Text File fix-npe-on-insert-of-autogenkey.txt (1 kB)

Environment: Mac Snow Leopard

Datastore: Other


 Description  « Hide
An NPE occurs running the tutorial using the JDO version.


Jim-Whites-MacBook-Pro:datanucleus-samples-jdo-tutorial-3.1 jim$ ant runtutorial
Buildfile: /Users/jim/Downloads/datanucleus-samples-jdo-tutorial-3.1/build.xml

runtutorial:
     [java] DataNucleus AccessPlatform with JDO
     [java] ===================================
     [java] Persisting Inventory of products
     [java] 12/07/31 21:49:58 ERROR DataNucleus.Persistence: Exception inserting object StateManager[pc=org.datanucleus.samples.jdo.tutorial.Inventory@622209db, lifecycle=P_NEW]
     [java] java.lang.NullPointerException
     [java] at org.datanucleus.store.neo4j.Neo4jUtils.getNodeForObjectProvider(Neo4jUtils.java:98)
     [java] at org.datanucleus.store.neo4j.Neo4jPersistenceHandler.locateObject(Neo4jPersistenceHandler.java:541)
     [java] at org.datanucleus.store.neo4j.Neo4jPersistenceHandler.insertObject(Neo4jPersistenceHandler.java:87)
     [java] at org.datanucleus.state.JDOStateManager.internalMakePersistent(JDOStateManager.java:2377)
     [java] at org.datanucleus.state.JDOStateManager.makePersistent(JDOStateManager.java:2353)
     [java] at org.datanucleus.ObjectManagerImpl.persistObjectInternal(ObjectManagerImpl.java:1905)
     [java] at org.datanucleus.ObjectManagerImpl.persistObjectInternal(ObjectManagerImpl.java:1993)
     [java] at org.datanucleus.store.neo4j.fieldmanager.StoreFieldManager.storeObjectField(StoreFieldManager.java:410)
     [java] at org.datanucleus.state.AbstractStateManager.providedObjectField(AbstractStateManager.java:1447)
     [java] at org.datanucleus.samples.jdo.tutorial.Inventory.jdoProvideField(Inventory.java)
     [java] at org.datanucleus.samples.jdo.tutorial.Inventory.jdoProvideFields(Inventory.java)
     [java] at org.datanucleus.state.AbstractStateManager.provideFields(AbstractStateManager.java:1515)
     [java] at org.datanucleus.store.neo4j.Neo4jPersistenceHandler.insertObject(Neo4jPersistenceHandler.java:221)
     [java] at org.datanucleus.state.JDOStateManager.internalMakePersistent(JDOStateManager.java:2377)
     [java] at org.datanucleus.state.JDOStateManager.makePersistent(JDOStateManager.java:2353)
     [java] at org.datanucleus.ObjectManagerImpl.persistObjectInternal(ObjectManagerImpl.java:1905)
     [java] at org.datanucleus.ObjectManagerImpl.persistObjectWork(ObjectManagerImpl.java:1754)
     [java] at org.datanucleus.ObjectManagerImpl.persistObject(ObjectManagerImpl.java:1601)
     [java] at org.datanucleus.api.jdo.JDOPersistenceManager.jdoMakePersistent(JDOPersistenceManager.java:730)
     [java] at org.datanucleus.api.jdo.JDOPersistenceManager.makePersistent(JDOPersistenceManager.java:755)
     [java] at org.datanucleus.samples.jdo.tutorial.Main.main(Main.java:58)
     [java] Exception in thread "main" javax.jdo.JDODataStoreException: Exception inserting object for StateManager[pc=org.datanucleus.samples.jdo.tutorial.Inventory@622209db, lifecycle=P_NEW]
     [java] at org.datanucleus.api.jdo.NucleusJDOHelper.getJDOExceptionForNucleusException(NucleusJDOHelper.java:421)
     [java] at org.datanucleus.api.jdo.JDOPersistenceManager.jdoMakePersistent(JDOPersistenceManager.java:735)
     [java] at org.datanucleus.api.jdo.JDOPersistenceManager.makePersistent(JDOPersistenceManager.java:755)
     [java] at org.datanucleus.samples.jdo.tutorial.Main.main(Main.java:58)
     [java] NestedThrowablesStackTrace:
     [java] java.lang.NullPointerException
     [java] at org.datanucleus.store.neo4j.Neo4jUtils.getNodeForObjectProvider(Neo4jUtils.java:98)
     [java] at org.datanucleus.store.neo4j.Neo4jPersistenceHandler.locateObject(Neo4jPersistenceHandler.java:541)
     [java] at org.datanucleus.store.neo4j.Neo4jPersistenceHandler.insertObject(Neo4jPersistenceHandler.java:87)
     [java] at org.datanucleus.state.JDOStateManager.internalMakePersistent(JDOStateManager.java:2377)
     [java] at org.datanucleus.state.JDOStateManager.makePersistent(JDOStateManager.java:2353)
     [java] at org.datanucleus.ObjectManagerImpl.persistObjectInternal(ObjectManagerImpl.java:1905)
     [java] at org.datanucleus.ObjectManagerImpl.persistObjectInternal(ObjectManagerImpl.java:1993)
     [java] at org.datanucleus.store.neo4j.fieldmanager.StoreFieldManager.storeObjectField(StoreFieldManager.java:410)
     [java] at org.datanucleus.state.AbstractStateManager.providedObjectField(AbstractStateManager.java:1447)
     [java] at org.datanucleus.samples.jdo.tutorial.Inventory.jdoProvideField(Inventory.java)
     [java] at org.datanucleus.samples.jdo.tutorial.Inventory.jdoProvideFields(Inventory.java)
     [java] at org.datanucleus.state.AbstractStateManager.provideFields(AbstractStateManager.java:1515)
     [java] at org.datanucleus.store.neo4j.Neo4jPersistenceHandler.insertObject(Neo4jPersistenceHandler.java:221)
     [java] at org.datanucleus.state.JDOStateManager.internalMakePersistent(JDOStateManager.java:2377)
     [java] at org.datanucleus.state.JDOStateManager.makePersistent(JDOStateManager.java:2353)
     [java] at org.datanucleus.ObjectManagerImpl.persistObjectInternal(ObjectManagerImpl.java:1905)
     [java] at org.datanucleus.ObjectManagerImpl.persistObjectWork(ObjectManagerImpl.java:1754)
     [java] at org.datanucleus.ObjectManagerImpl.persistObject(ObjectManagerImpl.java:1601)
     [java] at org.datanucleus.api.jdo.JDOPersistenceManager.jdoMakePersistent(JDOPersistenceManager.java:730)
     [java] at org.datanucleus.api.jdo.JDOPersistenceManager.makePersistent(JDOPersistenceManager.java:755)
     [java] at org.datanucleus.samples.jdo.tutorial.Main.main(Main.java:58)
     [java] Java Result: 1


Jim White added a comment - 01/Aug/12 08:50 AM
The problem is that Neo4Utils.getNodeForObjectProvider gets a null key when locateObject is called to see if the object is already in the store (there is a temporary id object and it is not a SingleFieldIdentity). I fixed it by checking for the null key value and throwing a NucleusObjectNotFoundException which is what insertObject is looking for.

Jim White added a comment - 01/Aug/12 08:52 AM
My patch to workaround the problem. Obviously I have no idea if this is right (my first time trying out Datanucleus) but it seems reasonable to me (although I don't understand how the tutorial works for anyone else...).

Jim White made changes - 01/Aug/12 08:52 AM
Field Original Value New Value
Attachment fix-npe-on-insert-of-autogenkey.txt [ 11699 ]
Andy Jefferson added a comment - 01/Aug/12 09:25 AM
SVN trunk (and nightly build fixes that)

Andy Jefferson made changes - 01/Aug/12 09:25 AM
Status Open [ 1 ] Resolved [ 5 ]
Fix Version/s 3.1.0.m2 [ 11637 ]
Resolution Fixed [ 1 ]
Andy Jefferson made changes - 02/Aug/12 03:08 PM
Status Resolved [ 5 ] Closed [ 6 ]