· neo4j

neo4j: WrappingNeoServerBootstrapper and the case of the /webadmin 404

When people first use neo4j they frequently start out by embedding it in a Java application but eventually they want to explore the graph in a more visual way.

One simple way to do this is to start neo4j in server mode and use the web console.

Our initial code might read like this:

public class GraphMeUp {
    public static void main(String[] args) {
        GraphDatabaseService graphDb = new EmbeddedGraphDatabase("/path/to/data/graph.db");
    }
}

or:

public class GraphMeUp {
    public static void main(String[] args) {
        GraphDatabaseService graphDb = new GraphDatabaseFactory().
          newEmbeddedDatabaseBuilder("/path/to/data/graph.db").
          newGraphDatabase();
    }
}

And to start our graph up in server mode we can use the http://components.neo4j.org/neo4j-server/1.9/apidocs/org/neo4j/server/WrappingNeoServerBootstrapper.html class which is packaged in neo4j-server so we first need to add that dependency:

 <dependency>
    <groupId>org.neo4j.app</groupId>
    <artifactId>neo4j-server</artifactId>
    <version>1.9</version>
</dependency>
public class GraphMeUp {
    public static void main(String[] args) {
        GraphDatabaseService graphDb = new GraphDatabaseFactory().
          newEmbeddedDatabaseBuilder("/path/to/data/graph.db").
          newGraphDatabase();

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

If we then browse to http://localhost:7474/webadmin/ we’ll be greeted by a 404 error:

HTTP ERROR 404

Problem accessing /webadmin/. Reason:

    Not Found
Powered by Jetty://

sad panda :(

Until I came across this post on StackOverflow by Michael I didn’t realise that there’s actually another dependency that we need to include to get the web admin goodness!

To get things worked as we’d expect we need to include the following dependency: ~xml org.neo4j.app neo4j-server 1.9 jar static-web compile ~

I hadn’t come across the classifier attribute before but what this does is include the following JAR: ~bash $ ls -alh ~/.m2/repository/org/neo4j/app/neo4j-server/1.9/neo4j-server-1.9-static-web.jar -rw-r—​r-- 1 markhneedham staff 3.5M 17 Jun 11:28 /Users/markhneedham/.m2/repository/org/neo4j/app/neo4j-server/1.9/neo4j-server-1.9-static-web.jar ~

If we run our code again we should see the bright and cheery web admin interface and all is good with the world.

  • LinkedIn
  • Tumblr
  • Reddit
  • Google+
  • Pinterest
  • Pocket