【发布时间】:2018-11-29 11:12:46
【问题描述】:
我正在尝试查找一些示例或演示“如何将 OGM 与非托管扩展集成”,但找不到任何好的示例。
我尝试将 restapi 用作非托管扩展,并且单独使用它可以正常工作,但 OGM 具有智能对象映射功能,可以通过 Session 和 Session 来实现
SessionFactory.
private final static SessionFactory sessionFactory = new SessionFactory("some.domain");
sessionFactory .openSession();
现在如何使用 OGM 与非托管扩展集成?
有人可以帮我做同样的事情吗?
编辑 1
编辑 2
下面是我们写的代码
import org.neo4j.ogm.drivers.embedded.extension.OgmPluginInitializer;
public class MyApplicationPluginInitializer extends OgmPluginInitializer {
public MyApplicationPluginInitializer(String packages) {
super(packages);
}
}
类 TopologyExtController
@Path("/")
public class TopologyExtController {
@javax.ws.rs.core.Context
public org.neo4j.ogm.session.Session session;
public TopologyExtController( ) {
}
@POST
@Path("/uiv/topology")
public Response getTopology(TopologyDescription topology, @javax.ws.rs.core.Context HttpHeaders headers) {
try{
ObjectMapper mapper = new ObjectMapper();
Map convertValue = mapper.convertValue(topology, Map.class);
Map<String, Object> map = new HashMap<>();
map.put("topology", convertValue);
//OGM session used execute the procedure and return the mapped result to end user.
Result query = session.query("call uiv.traversal($topology)",map);
Iterator<Map<String, Object>> iterator = query.iterator();
if (iterator.hasNext()) {
Map<String, Object> next = iterator.next();
Object object = next.get("rootNodes");
return Response.ok(object).status(200).build();
}
}catch (Exception e)
{
e.printStackTrace();
}
return Response.ok("Something went wrong").status(400).build();
}
}
META-INF 条目 \META-INF\services\org.neo4j.server.plugins.PluginLifecycle
- framework.traversal.ext.config.MyApplicationPluginInitializer
但是我们得到的错误
11 月 30 日 15:17:27 surerest2 neo4j: 2018-11-30 09:47:27.611+0000 错误 使用资源检测到以下错误和警告 和/或提供者类:11 月 30 日 15:17:27 surerest2 neo4j:严重: 缺少字段依赖项:public org.neo4j.ogm.session.Session framework.traversal.ext.ogm.controller.TopologyExtController.session 11 月 30 日 15:17:27 surerest2 neo4j: 2018-11-30 09:47:27.612+0000 警告 11 月 30 日 15:17:27 不可用 com.sun.jersey.spi.inject.Errors$ErrorMessagesException 11 月 30 日 15:17:27 surerest2 neo4j:在 com.sun.jersey.spi.inject.Errors.processErrorMessages(Errors.java:170) 11 月 30 日 15:17:27surerest2 neo4j:在 com.sun.jersey.spi.inject.Errors.postProcess(Errors.java:136)11 月 30 日 15:17:27 surerest2 neo4j:在 com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:199) 11 月 30 日 15:17:27surerest2 neo4j:在 com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:795) 11 月 30 日 15:17:27surerest2 neo4j:在 com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:790) 11 月 30 日 15:17:27surerest2 neo4j:在 com.sun.jersey.spi.container.servlet.ServletContainer.initiate(ServletContainer.java:509) 11 月 30 日 15:17:27surerest2 neo4j:在 com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.initiate(ServletContainer.java:339) 11 月 30 日 15:17:27surerest2 neo4j:在 com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:605) 11 月 30 日 15:17:27surerest2 neo4j:在 com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:207) 11 月 30 日 15:17:27surerest2 neo4j:在 com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:394) 11 月 30 日 15:17:27surerest2 neo4j:在 com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:577) 11 月 30 日 15:17:27surerest2 neo4j:在 javax.servlet.GenericServlet.init(GenericServlet.java:244) 11 月 30 日 15:17:27 surerest2 neo4j:在 org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:665) 11 月 30 日 15:17:27surerest2 neo4j:在 org.eclipse.jetty.servlet.ServletHolder.initialize(ServletHolder.java:423) 11 月 30 日 15:17:27surerest2 neo4j:在 org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:760) 11 月 30 日 15:17:27surerest2 neo4j:在 org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:348) 11 月 30 日 15:17:27surerest2 neo4j:在 org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:785) 11 月 30 日 15:17:27surerest2 neo4j:在 org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:261) 11 月 30 日 15:17:27surerest2 neo4j:在 org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) 11 月 30 日 15:17:27surerest2 neo4j:在 org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:133) 11 月 30 日 15:17:27surerest2 neo4j:在 org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:115) 11 月 30 日 15:17:27surerest2 neo4j:在 org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113) 11 月 30 日 15:17:27surerest2 neo4j:在 org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) 11 月 30 日 15:17:27surerest2 neo4j:在 org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:133) 11 月 30 日 15:17:27surerest2 neo4j:在 org.eclipse.jetty.server.Server.start(Server.java:418) 11 月 30 日 15:17:27 surerest2 neo4j:在 org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:107) 11 月 30 日 15:17:27surerest2 neo4j:在 org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113) 11 月 30 日 15:17:27surerest2 neo4j:在 org.eclipse.jetty.server.Server.doStart(Server.java:385) 11 月 30 日 15:17:27 surerest2 neo4j:在 org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) 11 月 30 日 15:17:27surerest2 neo4j:在 org.neo4j.server.web.Jetty9WebServer.startJetty(Jetty9WebServer.java:320) 11 月 30 日 15:17:27surerest2 neo4j:在 org.neo4j.server.web.Jetty9WebServer.start(Jetty9WebServer.java:152) 11 月 30 日 15:17:27surerest2 neo4j:在 org.neo4j.server.AbstractNeoServer.startWebServer(AbstractNeoServer.java:321) 11 月 30 日 15:17:27surerest2 neo4j:在 org.neo4j.server.AbstractNeoServer.access$700(AbstractNeoServer.java:102) 11 月 30 日 15:17:27surerest2 neo4j:在 org.neo4j.server.AbstractNeoServer$ServerComponentsLifecycleAdapter.start(AbstractNeoServer.java:527) 11 月 30 日 15:17:27surerest2 neo4j:在 org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:445) 11 月 30 日 15:17:27surerest2 neo4j:在 org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:107) 十一月 30 15:17:27surerest2 neo4j:在 org.neo4j.server.AbstractNeoServer.start(AbstractNeoServer.java:212) 11 月 30 日 15:17:27surerest2 neo4j:在 org.neo4j.server.ServerBootstrapper.start(ServerBootstrapper.java:111) 11 月 30 日 15:17:27surerest2 neo4j:在 org.neo4j.server.ServerBootstrapper.start(ServerBootstrapper.java:79) 11 月 30 日 15:17:27surerest2 neo4j:在 com.neo4j.server.enterprise.CommercialEntryPoint.main(CommercialEntryPoint.java:22) 11 月 30 日 15:17:27 surerest2 neo4j: 2018-11-30 09:47:27.639+0000 错误 在 127.0.0.1:7474 上启动 Neo4j 失败: org.neo4j.server.web.NeoServletContainer-737fd68@2dde7c07==org.neo4j.server.web.NeoServletContainer,jsp=null,order=-1,inst=false Nov 30 15:17:27 surerest2 neo4j: 2018-11 -30 09:47:27.658+0000 信息 停止... 11 月 30 日 15:17:28 surerest2 neo4j: 2018-11-30 09:47:28.279+0000 信息已停止。 11 月 30 日 15:17:28 2018-11-30 09:47:28.281+0000 错误无法启动 Neo4j:正在启动 Neo4j 失败:组件 'org.neo4j.server.AbstractNeoServer$ServerComponentsLifecycleAdapter@6c49db66' 已成功初始化,但无法启动。请参阅 附加原因异常“空”。启动 Neo4j 失败:组件 'org.neo4j.server.AbstractNeoServer$ServerComponentsLifecycleAdapter@6c49db66' 已成功初始化,但无法启动。请参阅 附加原因异常“空”。 11 月 30 日 15:17:28 org.neo4j.server.ServerStartupException:启动 Neo4j 失败: 零件 'org.neo4j.server.AbstractNeoServer$ServerComponentsLifecycleAdapter@6c49db66' 已成功初始化,但无法启动。请参阅 附加原因异常“空”。 11 月 30 日 15:17:28surerest2 neo4j:在 org.neo4j.server.exception.ServerStartupErrors.translateToServerStartupError(ServerStartupErrors.java:68) 11 月 30 日 15:17:28surerest2 neo4j:在 org.neo4j.server.AbstractNeoServer.start(AbstractNeoServer.java:220) 11 月 30 日 15:17:28surerest2 neo4j:在 org.neo4j.server.ServerBootstrapper.start(ServerBootstrapper.java:111) 11 月 30 日 15:17:28surerest2 neo4j:在 org.neo4j.server.ServerBootstrapper.start(ServerBootstrapper.java:79) 11 月 30 日 15:17:28surerest2 neo4j:在 com.neo4j.server.enterprise.CommercialEntryPoint.main(CommercialEntryPoint.java:22) 11 月 30 日 15:17:28 surerest2 neo4j: 原因: org.neo4j.kernel.lifecycle.LifecycleException:组件 'org.neo4j.server.AbstractNeoServer$ServerComponentsLifecycleAdapter@6c49db66' 已成功初始化,但无法启动。请参阅 附加原因异常“空”。 11 月 30 日 15:17:28surerest2 neo4j:在 org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:466) 11 月 30 日 15:17:28surerest2 neo4j:在 org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:107) 十一月 30 15:17:28surerest2 neo4j:在 org.neo4j.server.AbstractNeoServer.start(AbstractNeoServer.java:212) 11 月 30 日 15:17:28surerest2 neo4j:... 3 更多 11 月 30 日 15:17:28surerest2 neo4j:引起:javax.servlet.ServletException: org.neo4j.server.web.NeoServletContainer-737fd68@2dde7c07==org.neo4j.server.web.NeoServletContainer,jsp=null,order=-1,inst=false 11 月 30 日 15:17:28 surerest2 neo4j: at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:686) 11 月 30 日 15:17:28surerest2 neo4j:在 org.eclipse.jetty.servlet.ServletHolder.initialize(ServletHolder.java:423) 11 月 30 日 15:17:28surerest2 neo4j:在 org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:760) 11 月 30 日 15:17:28surerest2 neo4j:在 org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:348) 11 月 30 日 15:17:28surerest2 neo4j:在 org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:785) 11 月 30 日 15:17:28surerest2 neo4j:在 org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:261) 11 月 30 日 15:17:28surerest2 neo4j:在 org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) 11 月 30 日 15:17:28surerest2 neo4j:在 org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:133) 11 月 30 日 15:17:28surerest2 neo4j:在 org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:115) 11 月 30 日 15:17:28surerest2 neo4j:在 org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113) 11 月 30 日 15:17:28surerest2 neo4j:在 org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) 11 月 30 日 15:17:28surerest2 neo4j:在 org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:133) 11 月 30 日 15:17:28surerest2 neo4j:在 org.eclipse.jetty.server.Server.start(Server.java:418) 11 月 30 日 15:17:28 surerest2 neo4j:在 org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:107) 11 月 30 日 15:17:28surerest2 neo4j:在 org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113) 11 月 30 日 15:17:28surerest2 neo4j:在 org.eclipse.jetty.server.Server.doStart(Server.java:385) 11 月 30 日 15:17:28 surerest2 neo4j:在 org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) 11 月 30 日 15:17:28surerest2 neo4j:在 org.neo4j.server.web.Jetty9WebServer.startJetty(Jetty9WebServer.java:320) 11 月 30 日 15:17:28surerest2 neo4j:在 org.neo4j.server.web.Jetty9WebServer.start(Jetty9WebServer.java:152) 11 月 30 日 15:17:28surerest2 neo4j:在 org.neo4j.server.AbstractNeoServer.startWebServer(AbstractNeoServer.java:321) 11 月 30 日 15:17:28surerest2 neo4j:在 org.neo4j.server.AbstractNeoServer.access$700(AbstractNeoServer.java:102) 11 月 30 日 15:17:28surerest2 neo4j:在 org.neo4j.server.AbstractNeoServer$ServerComponentsLifecycleAdapter.start(AbstractNeoServer.java:527) 11 月 30 日 15:17:28surerest2 neo4j:在 org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:445) 11 月 30 日 15:17:28surerest2 neo4j: ... 5 更多 11 月 30 日 15:17:28surerest2 neo4j:由以下原因引起: com.sun.jersey.spi.inject.Errors$ErrorMessagesException 11 月 30 日 15:17:28 surerest2 neo4j:在 com.sun.jersey.spi.inject.Errors.processErrorMessages(Errors.java:170) 11 月 30 日 15:17:28surerest2 neo4j:在 com.sun.jersey.spi.inject.Errors.postProcess(Errors.java:136)11 月 30 日 15:17:28 surerest2 neo4j:在 com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:199) 11 月 30 日 15:17:28surerest2 neo4j:在 com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:795) 11 月 30 日 15:17:28surerest2 neo4j:在 com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:790) 11 月 30 日 15:17:28surerest2 neo4j:在 com.sun.jersey.spi.container.servlet.ServletContainer.initiate(ServletContainer.java:509) 11 月 30 日 15:17:28surerest2 neo4j:在 com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.initiate(ServletContainer.java:339) 11 月 30 日 15:17:28surerest2 neo4j:在 com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:605) 11 月 30 日 15:17:28surerest2 neo4j:在 com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:207) 11 月 30 日 15:17:28surerest2 neo4j:在 com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:394) 11 月 30 日 15:17:28surerest2 neo4j:在 com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:577) 11 月 30 日 15:17:28surerest2 neo4j:在 javax.servlet.GenericServlet.init(GenericServlet.java:244) 11 月 30 日 15:17:28 surerest2 neo4j:在 org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:665) 11 月 30 日 15:17:28 surerest2 neo4j: ... 27 更多
【问题讨论】:
标签: neo4j spring-data-neo4j neo4j-ogm