Reputation: 1685
ORIGNAL POST
Let me start off with my code. This is the fragment of code where the error appears.
DatabaseModuleInterface dbModule = new DatabaseModuleImpl();
System.out.println(dbModule.getDb());
Traverser t = dbModule.getGraphTree(usernode);
System.out.println("DBMODULE = " + dbModule.toString());
System.out.println("USERNODE = " + usernode);
System.out.println("TRAVERSER1 = " + dbModule.getGraphTree(usernode));
System.out.println("T IS NOT NULL");
if (t.nodes() != null) {
System.out.println("T NODES IS NOT NULL");
for (Node node : t.nodes()) {
if (node != null) {
System.out.println("NODE IS NOT NULL");
} else {
System.out.println("NODE IS NULL");
}
}
}
Which returns
INFO: EmbeddedGraphDatabase [C:\impactordb]
INFO: DBMODULE = be.archimiddle.impactor.modules.database.interfaces.DatabaseModuleImpl@bed5ea
INFO: USERNODE = Node[241]
INFO: TRAVERSER1 = org.neo4j.kernel.impl.traversal.TraverserImpl@ce2016
INFO: T IS NOT NULL
INFO: T NODES IS NOT NULL
And then comes the error with following stack trace
java.lang.NullPointerException
at org.neo4j.kernel.impl.nioneo.xa.ReadTransaction.nodeLoadLight(ReadTransaction.java:86)
at org.neo4j.kernel.impl.persistence.PersistenceManager.loadLightNode(PersistenceManager.java:82)
at org.neo4j.kernel.impl.core.NodeManager.getLightNode(NodeManager.java:423)
at org.neo4j.kernel.impl.core.NodeManager.getNodeForProxy(NodeManager.java:440)
at org.neo4j.kernel.InternalAbstractGraphDatabase$4.lookup(InternalAbstractGraphDatabase.java:660)
at org.neo4j.kernel.impl.core.NodeProxy.getRelationships(NodeProxy.java:98)
at org.neo4j.kernel.StandardExpander$RegularExpander.doExpand(StandardExpander.java:579)
at org.neo4j.kernel.StandardExpander$RelationshipExpansion.iterator(StandardExpander.java:194)
at org.neo4j.kernel.impl.traversal.TraversalBranchWithState.expandRelationshipsWithoutChecks(TraversalBranchWithState.java:78)
at org.neo4j.kernel.impl.traversal.TraversalBranchImpl.expandRelationships(TraversalBranchImpl.java:104)
at org.neo4j.kernel.impl.traversal.StartNodeTraversalBranch.next(StartNodeTraversalBranch.java:46)
at org.neo4j.kernel.impl.traversal.AsOneStartBranch.next(AsOneStartBranch.java:100)
at org.neo4j.kernel.PreorderDepthFirstSelector.next(PreorderDepthFirstSelector.java:52)
at org.neo4j.kernel.impl.traversal.TraverserIterator.fetchNextOrNull(TraverserIterator.java:64)
at org.neo4j.kernel.impl.traversal.TraverserIterator.fetchNextOrNull(TraverserIterator.java:33)
at org.neo4j.helpers.collection.PrefetchingIterator.hasNext(PrefetchingIterator.java:55)
at org.neo4j.helpers.collection.IteratorWrapper.hasNext(IteratorWrapper.java:42)
at com.archimiddle.impactor.action.navigation.ViewGraphAction.getGraphTree(ViewGraphAction.java:107)
This line #107 is the following line in the snippet:
for(Node node : t.nodes()){
I've checked everything for null values, and couldn't find anything. If anybody could help me, it would be greatly appreciated.
EDIT
I use this method to show the tree hidden in my graph. I know the method works because I can see my graph.
It's only that after I added nodes using the Neo4jgraph from tinkerpop blueprints, that I no longer can use the method to view my graph. In order for Gremlin to actually add the nodes to my Neo4J graph I have to call either a shutdown or a stopTransaction before the nodes are commited.
Neo4jgraph graph = new Neo4jGraph(my_graphdatabaseservice);
//ADD NODES HERE
//I USED TO DO THIS
neo4jgraph.shutdown();
//NOW I DO THIS
neo4jgraph.stopTransaction(Conclusion.SUCCESS);
I have to do either one of those two or my nodes won't be commmited. And I have to add them using Blueprints for a very specific reason.
I'm suspecting it has something to do with this since it only happens after I do this...
Upvotes: 1
Views: 176
Reputation: 1022
The problem is not related with the code-snippet you posted. Everything there is working fine.
The problem is with your neo4j implementation.
Try adding the following parameters to your neo4j configuration
Upvotes: 0