Neo4J意外停机或配置错误?

时间:2013-03-01 10:22:27

标签: java nullpointerexception neo4j

ORIGNAL POST

让我从我的代码开始。这是出现错误的代码片段。

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");
            }
        }
    }

返回

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

然后出现以下堆栈跟踪错误

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)

第#107行是代码段中的以下行:

for(Node node : t.nodes()){

我已经检查了所有空值,但找不到任何东西。如果有人可以帮助我,我将不胜感激。

修改

我使用此方法显示隐藏在图表中的树。我知道这个方法有效,因为我可以看到我的图表。

只有在我使用来自tinkerpop蓝图的Neo4jgraph添加节点后,才能使用该方法查看我的图表。为了让Gremlin实际将节点添加到我的Neo4J图中,我必须在提交节点之前调用shutdown或stopTransaction。

Neo4jgraph graph = new Neo4jGraph(my_graphdatabaseservice);
//ADD NODES HERE
//I USED TO DO THIS
neo4jgraph.shutdown();
//NOW I DO THIS
neo4jgraph.stopTransaction(Conclusion.SUCCESS);

我必须做这两个中的任何一个,否则我的节点将不会被提交。我必须使用蓝图添加它们,原因很简单。

我怀疑它与此有关,因为它只发生在我这样做之后......

1 个答案:

答案 0 :(得分:0)

问题与您发布的代码段无关。那里的一切都很好。

问题在于你的neo4j实现。

尝试将以下参数添加到neo4j配置

  • config.cache_classes = true
  • config.threadsafe!