嵌入式neo4j服务器和Web管理员同时进行

时间:2014-11-07 00:28:22

标签: neo4j graph-databases

我按照以下链接中的说明操作,但是,当我运行程序并转到http://localhost:7474/时,网络管理员的网页不可用。

How to connect to a locally installed neo4j server using Java

Neo4j Hello World Tutorial and webadmin

Wrapping server bootstrapper is deprecated, what is the alternative?

http://devender.wordpress.com/2011/10/17/neo4j-running-embedded-server-with-webconsole/

http://www.markhneedham.com/blog/2013/06/19/neo4j-wrappingneoserverbootstrapper-and-the-case-of-the-webadmin-404/

use WrappingNeoServerBootstrapper with spring-data-neo4j

我确实设法一个接一个地运行Java程序和neo4j服务器(指向相同的DB_PATH),但我需要的是同时运行程序和Web管理员,以便我可以看到程序在做什么实时。

任何想法我做错了或在2.1.5版本中根本不可能?

我的pom.xml具有以下依赖项:

<dependency>
    <groupId>org.neo4j</groupId>
    <artifactId>neo4j</artifactId>
    <version>2.1.5</version>
</dependency>
<dependency>
    <groupId>org.neo4j.app</groupId>
    <artifactId>neo4j-server</artifactId>
    <version>2.1.5</version>
</dependency>
<dependency>
    <groupId>org.neo4j.app</groupId>
    <artifactId>neo4j-server</artifactId>
    <version>2.1.5</version>
    <type>jar</type>
    <classifier>static-web</classifier>
</dependency>

Java程序包含:

private GraphDatabaseService graphDb = null;
private WrappingNeoServerBootstrapper server = null;

void start() {
    graphDb = new GraphDatabaseFactory()
    .newEmbeddedDatabase(DB_PATH);

    server = new WrappingNeoServerBootstrapper((GraphDatabaseAPI) graphDb);
    server.start();
}

更新

我注意到在我的项目文件夹中创建了一个文件messages.log。它表示服务器启动时存在NoSuchMethodError异常。您有任何想法如何解决这个问题吗?

2014-11-07 03:28:32.156+0000 ERROR [org.neo4j]: Failed to start Neo Server on port [7474] Starting Neo4j Server failed: org.eclipse.jetty.util.thread.QueuedThreadPool.<init>(IIILjava/util/concurrent/BlockingQueue;)V
org.neo4j.server.ServerStartupException: Starting Neo4j Server failed: org.eclipse.jetty.util.thread.QueuedThreadPool.<init>(IIILjava/util/concurrent/BlockingQueue;)V
at org.neo4j.server.AbstractNeoServer.start(AbstractNeoServer.java:226)
at org.neo4j.server.Bootstrapper.start(Bootstrapper.java:108)
at org.neo4j.server.Bootstrapper.start(Bootstrapper.java:89)
at org.example.url_receiver.Store.start(Store.java:20)
at org.example.url_receiver.Main.main(Main.java:11)
Caused by: java.lang.NoSuchMethodError: org.eclipse.jetty.util.thread.QueuedThreadPool.<init>(IIILjava/util/concurrent/BlockingQueue;)V
at org.neo4j.server.web.Jetty9WebServer.createQueuedThreadPool(Jetty9WebServer.java:189)
at org.neo4j.server.web.Jetty9WebServer.start(Jetty9WebServer.java:146)
at org.neo4j.server.AbstractNeoServer.startWebServer(AbstractNeoServer.java:432)
at org.neo4j.server.AbstractNeoServer.start(AbstractNeoServer.java:193)
... 4 more

1 个答案:

答案 0 :(得分:2)

这是我一直在使用的(在2.1.3上,希望在2.1.5上也一样) -

WrappingNeoServerBootstrapper neoServerBootstrapper;
GraphDatabaseService db = new GraphDatabaseFactory().newEmbeddedDatabaseBuilder("/path/to/db").newGraphDatabase();
registerShutdownHook(db);

try {
    GraphDatabaseAPI api = (GraphDatabaseAPI) db;
    ServerConfigurator config = new ServerConfigurator(api);
    config.configuration().addProperty(Configurator.WEBSERVER_ADDRESS_PROPERTY_KEY, "127.0.0.1");
    config.configuration().addProperty(Configurator.WEBSERVER_PORT_PROPERTY_KEY, "7575");
    neoServerBootstrapper = new WrappingNeoServerBootstrapper(api, config);
    neoServerBootstrapper.start();
}
catch(Exception e) {
    //log it
}