Mark Needham

Thoughts on Software Development

neo4j: WrappingNeoServerBootstrapper and the case of the /webadmin 404

without comments

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

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

I hadn’t come across the classifier attribute before but what this does is include the following JAR:

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

Written by Mark Needham

June 19th, 2013 at 5:32 am

Posted in neo4j

Tagged with