NoSQL Zone is brought to you in partnership with:

Mark is a graph advocate and field engineer for Neo Technology, the company behind the Neo4j graph database. As a field engineer, Mark helps customers embrace graph data and Neo4j building sophisticated solutions to challenging data problems. When he's not with customers Mark is a developer on Neo4j and writes his experiences of being a graphista on a popular blog at http://markhneedham.com/blog. He tweets at @markhneedham. Mark is a DZone MVB and is not an employee of DZone and has posted 534 posts at DZone. You can read more from them at their website. View Full User Profile

neo4j: WrappingNeoServerBootstrapper and the Case of the /webadmin 404

06.19.2013
| 1891 views |
  • submit to reddit

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.



Published at DZone with permission of Mark Needham, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)