user2360448
user2360448

Reputation: 63

Embedded neo4j server and web admin at the same time

I followed the instructions at the following links, however, when I run my program and go to http://localhost:7474/ the webpage of the web admin is not available.

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

I do manage to run Java program and neo4j server one after another (pointing at the same DB_PATH), but what I need is to run program and web admin at the same time, so that I can see what the program is doing in real-time.

Any ideas what I am doing wrong or is this simply not possible in version 2.1.5?

My pom.xml has the following dependencies:

<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>

The Java program contains this:

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

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

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

Update

I noticed that there is a file messages.log created in my project folder. It says that there is a NoSuchMethodError exception when the server is started. Do you have any ideas how to fix this?

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

Upvotes: 1

Views: 1588

Answers (1)

Luanne
Luanne

Reputation: 19373

Here's what I've been using (on 2.1.3, hopefully works the same on 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
}

Upvotes: 2

Related Questions