如何将 neo4j-ogm 与非托管扩展集成?
How to integrate neo4j-ogm with unmanaged extension?
我试图找到一些示例或演示 "How to integrate OGM with unmanaged extension" 但找不到任何好的示例。
我尝试将 restapi 用作非托管扩展并单独使用它工作正常但 OGM 具有智能对象映射功能并且可以通过 Session
实现并且 Session
是从
SessionFactory
.
private final static SessionFactory sessionFactory = new SessionFactory("some.domain");
sessionFactory .openSession();
现在如何使用 OGM 与 Unmanaged Extension 集成?
有人可以帮我做同样的事情吗?
编辑 1
请查看下面的屏幕截图
编辑 2
下面是我们写的代码
import org.neo4j.ogm.drivers.embedded.extension.OgmPluginInitializer;
public class MyApplicationPluginInitializer extends OgmPluginInitializer {
public MyApplicationPluginInitializer(String packages) {
super(packages);
}
}
Class 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
但是我们遇到了错误
Nov 30 15:17:27 surerest2 neo4j: 2018-11-30 09:47:27.611+0000 ERROR
The following errors and warnings have been detected with resource
and/or provider classes: Nov 30 15:17:27 surerest2 neo4j: SEVERE:
Missing dependency for field: public org.neo4j.ogm.session.Session
framework.traversal.ext.ogm.controller.TopologyExtController.session
Nov 30 15:17:27 surerest2 neo4j: 2018-11-30 09:47:27.612+0000 WARN
unavailable Nov 30 15:17:27 surerest2 neo4j:
com.sun.jersey.spi.inject.Errors$ErrorMessagesException Nov 30
15:17:27 surerest2 neo4j: at
com.sun.jersey.spi.inject.Errors.processErrorMessages(Errors.java:170)
Nov 30 15:17:27 surerest2 neo4j: at
com.sun.jersey.spi.inject.Errors.postProcess(Errors.java:136) Nov 30
15:17:27 surerest2 neo4j: at
com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:199)
Nov 30 15:17:27 surerest2 neo4j: at
com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:795)
Nov 30 15:17:27 surerest2 neo4j: at
com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:790)
Nov 30 15:17:27 surerest2 neo4j: at
com.sun.jersey.spi.container.servlet.ServletContainer.initiate(ServletContainer.java:509)
Nov 30 15:17:27 surerest2 neo4j: at
com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.initiate(ServletContainer.java:339)
Nov 30 15:17:27 surerest2 neo4j: at
com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:605)
Nov 30 15:17:27 surerest2 neo4j: at
com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:207)
Nov 30 15:17:27 surerest2 neo4j: at
com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:394)
Nov 30 15:17:27 surerest2 neo4j: at
com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:577)
Nov 30 15:17:27 surerest2 neo4j: at
javax.servlet.GenericServlet.init(GenericServlet.java:244) Nov 30
15:17:27 surerest2 neo4j: at
org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:665)
Nov 30 15:17:27 surerest2 neo4j: at
org.eclipse.jetty.servlet.ServletHolder.initialize(ServletHolder.java:423)
Nov 30 15:17:27 surerest2 neo4j: at
org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:760)
Nov 30 15:17:27 surerest2 neo4j: at
org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:348)
Nov 30 15:17:27 surerest2 neo4j: at
org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:785)
Nov 30 15:17:27 surerest2 neo4j: at
org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:261)
Nov 30 15:17:27 surerest2 neo4j: at
org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
Nov 30 15:17:27 surerest2 neo4j: at
org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:133)
Nov 30 15:17:27 surerest2 neo4j: at
org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:115)
Nov 30 15:17:27 surerest2 neo4j: at
org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
Nov 30 15:17:27 surerest2 neo4j: at
org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
Nov 30 15:17:27 surerest2 neo4j: at
org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:133)
Nov 30 15:17:27 surerest2 neo4j: at
org.eclipse.jetty.server.Server.start(Server.java:418) Nov 30 15:17:27
surerest2 neo4j: at
org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:107)
Nov 30 15:17:27 surerest2 neo4j: at
org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
Nov 30 15:17:27 surerest2 neo4j: at
org.eclipse.jetty.server.Server.doStart(Server.java:385) Nov 30
15:17:27 surerest2 neo4j: at
org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
Nov 30 15:17:27 surerest2 neo4j: at
org.neo4j.server.web.Jetty9WebServer.startJetty(Jetty9WebServer.java:320)
Nov 30 15:17:27 surerest2 neo4j: at
org.neo4j.server.web.Jetty9WebServer.start(Jetty9WebServer.java:152)
Nov 30 15:17:27 surerest2 neo4j: at
org.neo4j.server.AbstractNeoServer.startWebServer(AbstractNeoServer.java:321)
Nov 30 15:17:27 surerest2 neo4j: at
org.neo4j.server.AbstractNeoServer.access0(AbstractNeoServer.java:102)
Nov 30 15:17:27 surerest2 neo4j: at
org.neo4j.server.AbstractNeoServer$ServerComponentsLifecycleAdapter.start(AbstractNeoServer.java:527)
Nov 30 15:17:27 surerest2 neo4j: at
org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:445)
Nov 30 15:17:27 surerest2 neo4j: at
org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:107) Nov
30 15:17:27 surerest2 neo4j: at
org.neo4j.server.AbstractNeoServer.start(AbstractNeoServer.java:212)
Nov 30 15:17:27 surerest2 neo4j: at
org.neo4j.server.ServerBootstrapper.start(ServerBootstrapper.java:111)
Nov 30 15:17:27 surerest2 neo4j: at
org.neo4j.server.ServerBootstrapper.start(ServerBootstrapper.java:79)
Nov 30 15:17:27 surerest2 neo4j: at
com.neo4j.server.enterprise.CommercialEntryPoint.main(CommercialEntryPoint.java:22)
Nov 30 15:17:27 surerest2 neo4j: 2018-11-30 09:47:27.639+0000 ERROR
Failed to start Neo4j on 127.0.0.1:7474:
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 INFO
Stopping... Nov 30 15:17:28 surerest2 neo4j: 2018-11-30
09:47:28.279+0000 INFO Stopped. Nov 30 15:17:28 surerest2 neo4j:
2018-11-30 09:47:28.281+0000 ERROR Failed to start Neo4j: Starting
Neo4j failed: Component
'org.neo4j.server.AbstractNeoServer$ServerComponentsLifecycleAdapter@6c49db66'
was successfully initialized, but failed to start. Please see the
attached cause exception "null". Starting Neo4j failed: Component
'org.neo4j.server.AbstractNeoServer$ServerComponentsLifecycleAdapter@6c49db66'
was successfully initialized, but failed to start. Please see the
attached cause exception "null". Nov 30 15:17:28 surerest2 neo4j:
org.neo4j.server.ServerStartupException: Starting Neo4j failed:
Component
'org.neo4j.server.AbstractNeoServer$ServerComponentsLifecycleAdapter@6c49db66'
was successfully initialized, but failed to start. Please see the
attached cause exception "null". Nov 30 15:17:28 surerest2 neo4j: at
org.neo4j.server.exception.ServerStartupErrors.translateToServerStartupError(ServerStartupErrors.java:68)
Nov 30 15:17:28 surerest2 neo4j: at
org.neo4j.server.AbstractNeoServer.start(AbstractNeoServer.java:220)
Nov 30 15:17:28 surerest2 neo4j: at
org.neo4j.server.ServerBootstrapper.start(ServerBootstrapper.java:111)
Nov 30 15:17:28 surerest2 neo4j: at
org.neo4j.server.ServerBootstrapper.start(ServerBootstrapper.java:79)
Nov 30 15:17:28 surerest2 neo4j: at
com.neo4j.server.enterprise.CommercialEntryPoint.main(CommercialEntryPoint.java:22)
Nov 30 15:17:28 surerest2 neo4j: Caused by:
org.neo4j.kernel.lifecycle.LifecycleException: Component
'org.neo4j.server.AbstractNeoServer$ServerComponentsLifecycleAdapter@6c49db66'
was successfully initialized, but failed to start. Please see the
attached cause exception "null". Nov 30 15:17:28 surerest2 neo4j: at
org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:466)
Nov 30 15:17:28 surerest2 neo4j: at
org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:107) Nov
30 15:17:28 surerest2 neo4j: at
org.neo4j.server.AbstractNeoServer.start(AbstractNeoServer.java:212)
Nov 30 15:17:28 surerest2 neo4j: ... 3 more Nov 30 15:17:28 surerest2
neo4j: Caused by: javax.servlet.ServletException:
org.neo4j.server.web.NeoServletContainer-737fd68@2dde7c07==org.neo4j.server.web.NeoServletContainer,jsp=null,order=-1,inst=false Nov 30 15:17:28 surerest2 neo4j: at
org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:686)
Nov 30 15:17:28 surerest2 neo4j: at
org.eclipse.jetty.servlet.ServletHolder.initialize(ServletHolder.java:423)
Nov 30 15:17:28 surerest2 neo4j: at
org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:760)
Nov 30 15:17:28 surerest2 neo4j: at
org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:348)
Nov 30 15:17:28 surerest2 neo4j: at
org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:785)
Nov 30 15:17:28 surerest2 neo4j: at
org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:261)
Nov 30 15:17:28 surerest2 neo4j: at
org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
Nov 30 15:17:28 surerest2 neo4j: at
org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:133)
Nov 30 15:17:28 surerest2 neo4j: at
org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:115)
Nov 30 15:17:28 surerest2 neo4j: at
org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
Nov 30 15:17:28 surerest2 neo4j: at
org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
Nov 30 15:17:28 surerest2 neo4j: at
org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:133)
Nov 30 15:17:28 surerest2 neo4j: at
org.eclipse.jetty.server.Server.start(Server.java:418) Nov 30 15:17:28
surerest2 neo4j: at
org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:107)
Nov 30 15:17:28 surerest2 neo4j: at
org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
Nov 30 15:17:28 surerest2 neo4j: at
org.eclipse.jetty.server.Server.doStart(Server.java:385) Nov 30
15:17:28 surerest2 neo4j: at
org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
Nov 30 15:17:28 surerest2 neo4j: at
org.neo4j.server.web.Jetty9WebServer.startJetty(Jetty9WebServer.java:320)
Nov 30 15:17:28 surerest2 neo4j: at
org.neo4j.server.web.Jetty9WebServer.start(Jetty9WebServer.java:152)
Nov 30 15:17:28 surerest2 neo4j: at
org.neo4j.server.AbstractNeoServer.startWebServer(AbstractNeoServer.java:321)
Nov 30 15:17:28 surerest2 neo4j: at
org.neo4j.server.AbstractNeoServer.access0(AbstractNeoServer.java:102)
Nov 30 15:17:28 surerest2 neo4j: at
org.neo4j.server.AbstractNeoServer$ServerComponentsLifecycleAdapter.start(AbstractNeoServer.java:527)
Nov 30 15:17:28 surerest2 neo4j: at
org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:445)
Nov 30 15:17:28 surerest2 neo4j: ... 5 more Nov 30 15:17:28 surerest2
neo4j: Caused by:
com.sun.jersey.spi.inject.Errors$ErrorMessagesException Nov 30
15:17:28 surerest2 neo4j: at
com.sun.jersey.spi.inject.Errors.processErrorMessages(Errors.java:170)
Nov 30 15:17:28 surerest2 neo4j: at
com.sun.jersey.spi.inject.Errors.postProcess(Errors.java:136) Nov 30
15:17:28 surerest2 neo4j: at
com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:199)
Nov 30 15:17:28 surerest2 neo4j: at
com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:795)
Nov 30 15:17:28 surerest2 neo4j: at
com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:790)
Nov 30 15:17:28 surerest2 neo4j: at
com.sun.jersey.spi.container.servlet.ServletContainer.initiate(ServletContainer.java:509)
Nov 30 15:17:28 surerest2 neo4j: at
com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.initiate(ServletContainer.java:339)
Nov 30 15:17:28 surerest2 neo4j: at
com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:605)
Nov 30 15:17:28 surerest2 neo4j: at
com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:207)
Nov 30 15:17:28 surerest2 neo4j: at
com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:394)
Nov 30 15:17:28 surerest2 neo4j: at
com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:577)
Nov 30 15:17:28 surerest2 neo4j: at
javax.servlet.GenericServlet.init(GenericServlet.java:244) Nov 30
15:17:28 surerest2 neo4j: at
org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:665)
Nov 30 15:17:28 surerest2 neo4j: ... 27 more
这通常是不可能的。 Neo4j-OGM 使用 Cypher 抽象出所有传输模式(Bolt、HTTP、嵌入式)。
...但是如果您的非托管扩展与您的业务逻辑完全分离(例如,没有事务边界也包含 Neo4j-OGM 调用),您可以直接通过 (Neo4j-OGM) HTTP 驱动程序创建调用:
HttpDriver httpDriver = (HttpDriver) sessionFactory.getDriver();
CloseableHttpResponse response = httpDriver.executeHttpRequest(new HttpGet("http://somewhere"));
response.getEntity().getContent()....
请注意,这只是使用原始连接的技巧。
编辑(为 运行 内部 Neo4j 添加信息):
如 in the documentation 所述,您需要提供自己的 OgmPluginInitializer
,就像您已经做的那样。但是您的 implementation/constructor 确实希望在某处提供包裹。加载扩展的服务扩展不知道您的包结构,因此初始化程序 class 应该看起来像……。喜欢
public class MyApplicationPluginInitializer extends OgmPluginInitializer {
public MyApplicationPluginInitializer() {
super("Your package to scan");
}
}
作为警告:用于提供此功能的 API 在 Neo4j 3.5 中已弃用。并可能在即将发布的版本中删除。因此,此功能也可能会根据更改进行重构或删除。
我试图找到一些示例或演示 "How to integrate OGM with unmanaged extension" 但找不到任何好的示例。
我尝试将 restapi 用作非托管扩展并单独使用它工作正常但 OGM 具有智能对象映射功能并且可以通过 Session
实现并且 Session
是从
SessionFactory
.
private final static SessionFactory sessionFactory = new SessionFactory("some.domain");
sessionFactory .openSession();
现在如何使用 OGM 与 Unmanaged Extension 集成?
有人可以帮我做同样的事情吗?
编辑 1
请查看下面的屏幕截图
编辑 2
下面是我们写的代码
import org.neo4j.ogm.drivers.embedded.extension.OgmPluginInitializer;
public class MyApplicationPluginInitializer extends OgmPluginInitializer {
public MyApplicationPluginInitializer(String packages) {
super(packages);
}
}
Class 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
但是我们遇到了错误
Nov 30 15:17:27 surerest2 neo4j: 2018-11-30 09:47:27.611+0000 ERROR The following errors and warnings have been detected with resource and/or provider classes: Nov 30 15:17:27 surerest2 neo4j: SEVERE: Missing dependency for field: public org.neo4j.ogm.session.Session framework.traversal.ext.ogm.controller.TopologyExtController.session Nov 30 15:17:27 surerest2 neo4j: 2018-11-30 09:47:27.612+0000 WARN unavailable Nov 30 15:17:27 surerest2 neo4j: com.sun.jersey.spi.inject.Errors$ErrorMessagesException Nov 30 15:17:27 surerest2 neo4j: at com.sun.jersey.spi.inject.Errors.processErrorMessages(Errors.java:170) Nov 30 15:17:27 surerest2 neo4j: at com.sun.jersey.spi.inject.Errors.postProcess(Errors.java:136) Nov 30 15:17:27 surerest2 neo4j: at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:199) Nov 30 15:17:27 surerest2 neo4j: at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:795) Nov 30 15:17:27 surerest2 neo4j: at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:790) Nov 30 15:17:27 surerest2 neo4j: at com.sun.jersey.spi.container.servlet.ServletContainer.initiate(ServletContainer.java:509) Nov 30 15:17:27 surerest2 neo4j: at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.initiate(ServletContainer.java:339) Nov 30 15:17:27 surerest2 neo4j: at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:605) Nov 30 15:17:27 surerest2 neo4j: at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:207) Nov 30 15:17:27 surerest2 neo4j: at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:394) Nov 30 15:17:27 surerest2 neo4j: at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:577) Nov 30 15:17:27 surerest2 neo4j: at javax.servlet.GenericServlet.init(GenericServlet.java:244) Nov 30 15:17:27 surerest2 neo4j: at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:665) Nov 30 15:17:27 surerest2 neo4j: at org.eclipse.jetty.servlet.ServletHolder.initialize(ServletHolder.java:423) Nov 30 15:17:27 surerest2 neo4j: at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:760) Nov 30 15:17:27 surerest2 neo4j: at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:348) Nov 30 15:17:27 surerest2 neo4j: at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:785) Nov 30 15:17:27 surerest2 neo4j: at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:261) Nov 30 15:17:27 surerest2 neo4j: at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) Nov 30 15:17:27 surerest2 neo4j: at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:133) Nov 30 15:17:27 surerest2 neo4j: at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:115) Nov 30 15:17:27 surerest2 neo4j: at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113) Nov 30 15:17:27 surerest2 neo4j: at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) Nov 30 15:17:27 surerest2 neo4j: at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:133) Nov 30 15:17:27 surerest2 neo4j: at org.eclipse.jetty.server.Server.start(Server.java:418) Nov 30 15:17:27 surerest2 neo4j: at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:107) Nov 30 15:17:27 surerest2 neo4j: at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113) Nov 30 15:17:27 surerest2 neo4j: at org.eclipse.jetty.server.Server.doStart(Server.java:385) Nov 30 15:17:27 surerest2 neo4j: at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) Nov 30 15:17:27 surerest2 neo4j: at org.neo4j.server.web.Jetty9WebServer.startJetty(Jetty9WebServer.java:320) Nov 30 15:17:27 surerest2 neo4j: at org.neo4j.server.web.Jetty9WebServer.start(Jetty9WebServer.java:152) Nov 30 15:17:27 surerest2 neo4j: at org.neo4j.server.AbstractNeoServer.startWebServer(AbstractNeoServer.java:321) Nov 30 15:17:27 surerest2 neo4j: at org.neo4j.server.AbstractNeoServer.access0(AbstractNeoServer.java:102) Nov 30 15:17:27 surerest2 neo4j: at org.neo4j.server.AbstractNeoServer$ServerComponentsLifecycleAdapter.start(AbstractNeoServer.java:527) Nov 30 15:17:27 surerest2 neo4j: at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:445) Nov 30 15:17:27 surerest2 neo4j: at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:107) Nov 30 15:17:27 surerest2 neo4j: at org.neo4j.server.AbstractNeoServer.start(AbstractNeoServer.java:212) Nov 30 15:17:27 surerest2 neo4j: at org.neo4j.server.ServerBootstrapper.start(ServerBootstrapper.java:111) Nov 30 15:17:27 surerest2 neo4j: at org.neo4j.server.ServerBootstrapper.start(ServerBootstrapper.java:79) Nov 30 15:17:27 surerest2 neo4j: at com.neo4j.server.enterprise.CommercialEntryPoint.main(CommercialEntryPoint.java:22) Nov 30 15:17:27 surerest2 neo4j: 2018-11-30 09:47:27.639+0000 ERROR Failed to start Neo4j on 127.0.0.1:7474: 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 INFO Stopping... Nov 30 15:17:28 surerest2 neo4j: 2018-11-30 09:47:28.279+0000 INFO Stopped. Nov 30 15:17:28 surerest2 neo4j: 2018-11-30 09:47:28.281+0000 ERROR Failed to start Neo4j: Starting Neo4j failed: Component 'org.neo4j.server.AbstractNeoServer$ServerComponentsLifecycleAdapter@6c49db66' was successfully initialized, but failed to start. Please see the attached cause exception "null". Starting Neo4j failed: Component 'org.neo4j.server.AbstractNeoServer$ServerComponentsLifecycleAdapter@6c49db66' was successfully initialized, but failed to start. Please see the attached cause exception "null". Nov 30 15:17:28 surerest2 neo4j: org.neo4j.server.ServerStartupException: Starting Neo4j failed: Component 'org.neo4j.server.AbstractNeoServer$ServerComponentsLifecycleAdapter@6c49db66' was successfully initialized, but failed to start. Please see the attached cause exception "null". Nov 30 15:17:28 surerest2 neo4j: at org.neo4j.server.exception.ServerStartupErrors.translateToServerStartupError(ServerStartupErrors.java:68) Nov 30 15:17:28 surerest2 neo4j: at org.neo4j.server.AbstractNeoServer.start(AbstractNeoServer.java:220) Nov 30 15:17:28 surerest2 neo4j: at org.neo4j.server.ServerBootstrapper.start(ServerBootstrapper.java:111) Nov 30 15:17:28 surerest2 neo4j: at org.neo4j.server.ServerBootstrapper.start(ServerBootstrapper.java:79) Nov 30 15:17:28 surerest2 neo4j: at com.neo4j.server.enterprise.CommercialEntryPoint.main(CommercialEntryPoint.java:22) Nov 30 15:17:28 surerest2 neo4j: Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.server.AbstractNeoServer$ServerComponentsLifecycleAdapter@6c49db66' was successfully initialized, but failed to start. Please see the attached cause exception "null". Nov 30 15:17:28 surerest2 neo4j: at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:466) Nov 30 15:17:28 surerest2 neo4j: at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:107) Nov 30 15:17:28 surerest2 neo4j: at org.neo4j.server.AbstractNeoServer.start(AbstractNeoServer.java:212) Nov 30 15:17:28 surerest2 neo4j: ... 3 more Nov 30 15:17:28 surerest2 neo4j: Caused by: javax.servlet.ServletException: org.neo4j.server.web.NeoServletContainer-737fd68@2dde7c07==org.neo4j.server.web.NeoServletContainer,jsp=null,order=-1,inst=false Nov 30 15:17:28 surerest2 neo4j: at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:686) Nov 30 15:17:28 surerest2 neo4j: at org.eclipse.jetty.servlet.ServletHolder.initialize(ServletHolder.java:423) Nov 30 15:17:28 surerest2 neo4j: at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:760) Nov 30 15:17:28 surerest2 neo4j: at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:348) Nov 30 15:17:28 surerest2 neo4j: at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:785) Nov 30 15:17:28 surerest2 neo4j: at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:261) Nov 30 15:17:28 surerest2 neo4j: at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) Nov 30 15:17:28 surerest2 neo4j: at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:133) Nov 30 15:17:28 surerest2 neo4j: at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:115) Nov 30 15:17:28 surerest2 neo4j: at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113) Nov 30 15:17:28 surerest2 neo4j: at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) Nov 30 15:17:28 surerest2 neo4j: at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:133) Nov 30 15:17:28 surerest2 neo4j: at org.eclipse.jetty.server.Server.start(Server.java:418) Nov 30 15:17:28 surerest2 neo4j: at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:107) Nov 30 15:17:28 surerest2 neo4j: at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113) Nov 30 15:17:28 surerest2 neo4j: at org.eclipse.jetty.server.Server.doStart(Server.java:385) Nov 30 15:17:28 surerest2 neo4j: at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) Nov 30 15:17:28 surerest2 neo4j: at org.neo4j.server.web.Jetty9WebServer.startJetty(Jetty9WebServer.java:320) Nov 30 15:17:28 surerest2 neo4j: at org.neo4j.server.web.Jetty9WebServer.start(Jetty9WebServer.java:152) Nov 30 15:17:28 surerest2 neo4j: at org.neo4j.server.AbstractNeoServer.startWebServer(AbstractNeoServer.java:321) Nov 30 15:17:28 surerest2 neo4j: at org.neo4j.server.AbstractNeoServer.access0(AbstractNeoServer.java:102) Nov 30 15:17:28 surerest2 neo4j: at org.neo4j.server.AbstractNeoServer$ServerComponentsLifecycleAdapter.start(AbstractNeoServer.java:527) Nov 30 15:17:28 surerest2 neo4j: at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:445) Nov 30 15:17:28 surerest2 neo4j: ... 5 more Nov 30 15:17:28 surerest2 neo4j: Caused by: com.sun.jersey.spi.inject.Errors$ErrorMessagesException Nov 30 15:17:28 surerest2 neo4j: at com.sun.jersey.spi.inject.Errors.processErrorMessages(Errors.java:170) Nov 30 15:17:28 surerest2 neo4j: at com.sun.jersey.spi.inject.Errors.postProcess(Errors.java:136) Nov 30 15:17:28 surerest2 neo4j: at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:199) Nov 30 15:17:28 surerest2 neo4j: at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:795) Nov 30 15:17:28 surerest2 neo4j: at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:790) Nov 30 15:17:28 surerest2 neo4j: at com.sun.jersey.spi.container.servlet.ServletContainer.initiate(ServletContainer.java:509) Nov 30 15:17:28 surerest2 neo4j: at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.initiate(ServletContainer.java:339) Nov 30 15:17:28 surerest2 neo4j: at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:605) Nov 30 15:17:28 surerest2 neo4j: at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:207) Nov 30 15:17:28 surerest2 neo4j: at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:394) Nov 30 15:17:28 surerest2 neo4j: at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:577) Nov 30 15:17:28 surerest2 neo4j: at javax.servlet.GenericServlet.init(GenericServlet.java:244) Nov 30 15:17:28 surerest2 neo4j: at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:665) Nov 30 15:17:28 surerest2 neo4j: ... 27 more
这通常是不可能的。 Neo4j-OGM 使用 Cypher 抽象出所有传输模式(Bolt、HTTP、嵌入式)。
...但是如果您的非托管扩展与您的业务逻辑完全分离(例如,没有事务边界也包含 Neo4j-OGM 调用),您可以直接通过 (Neo4j-OGM) HTTP 驱动程序创建调用:
HttpDriver httpDriver = (HttpDriver) sessionFactory.getDriver();
CloseableHttpResponse response = httpDriver.executeHttpRequest(new HttpGet("http://somewhere"));
response.getEntity().getContent()....
请注意,这只是使用原始连接的技巧。
编辑(为 运行 内部 Neo4j 添加信息):
如 in the documentation 所述,您需要提供自己的 OgmPluginInitializer
,就像您已经做的那样。但是您的 implementation/constructor 确实希望在某处提供包裹。加载扩展的服务扩展不知道您的包结构,因此初始化程序 class 应该看起来像……。喜欢
public class MyApplicationPluginInitializer extends OgmPluginInitializer {
public MyApplicationPluginInitializer() {
super("Your package to scan");
}
}
作为警告:用于提供此功能的 API 在 Neo4j 3.5 中已弃用。并可能在即将发布的版本中删除。因此,此功能也可能会根据更改进行重构或删除。