我能够很好地运行演示并在我的单元测试中构建一个图形构建器,但现在当我部署它并在我的本地服务器上运行时,我得到了一些但不是所有我调用的查找的NullPointerExceptions。
ProjectController pc = Lookup.getDefault().lookup(ProjectController.class);
pc.newProject();
workspace = pc.getCurrentWorkspace();
GraphController gc = Lookup.getDefault().lookup(GraphController.class);
GraphModel model = gc.getModel();
下面的堆栈跟踪:
Caused by: java.lang.NullPointerException
at com.network.manager.impl.NetworkLayoutManagerImpl.initGraphModel(NetworkLayoutManagerImpl.java:167)
at com.network.manager.impl.NetworkLayoutManagerImpl.convertNetworkToGraph(NetworkLayoutManagerImpl.java:49)
at com.network.manager.impl.NetworkChartManagerImpl.buildNetworkGEXF(NetworkChartManagerImpl.java:61)
at com.network.controller.LoadNetworkControllerImpl.loadNodesAndEdges(LoadNetworkControllerImpl.java:43)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:328)
at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:341)
at org.jboss.el.parser.AstPropertySuffix.invoke(AstPropertySuffix.java:58)
at org.jboss.el.parser.AstValue.invoke(AstValue.java:96)
at org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
... 139 more
我的GraphController“gc”在这种情况下是null,但是,我能够毫无问题地查找ProjectController。出于好奇,我添加了我需要的其他控制器(AttributeController和ExportController)并将它们打印出来。
(ProjectController --- GraphController --- AttributeController --- ExportController)
System.err.println(pc + " --- " + gc + " --- " + ac + " --- " + ec);
给我以下内容:
org.gephi.project.impl.ProjectControllerImpl@1b819521 --- null --- null --- org.gephi.io.exporter.impl.ExportControllerImpl@3412470a
我对Lookup API不太熟悉,所以这是一个完全的谜。我在Tomcat服务器上运行它。如果需要更多信息,请告诉我。
此处发布了类似的问题,gephi论坛没有回复。
Streaming Graph to Gephi using toolkit : NullPointerException
答案 0 :(得分:1)
查找取决于找到的文件META-INF/services
。 Tomcat似乎找不到GraphController和AttributeController的那些。应该有类似于在源文件中导入GraphController和AttributeController的文件。