Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

neo4j: WrappingNeoServerBootstrapper and the Case of the /webadmin 404

DZone's Guide to

neo4j: WrappingNeoServerBootstrapper and the Case of the /webadmin 404

· Database Zone
Free Resource

Download the Guide to Open Source Database Selection: MySQL vs. MariaDB and see how the side-by-side comparison of must-have features will ease the journey. Brought to you in partnership with MariaDB.

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.



Interested in reducing database costs by moving from Oracle Enterprise to open source subscription?  Read the total cost of ownership (TCO) analysis. Brought to you in partnership with MariaDB.

Topics:

Published at DZone with permission of Mark Needham, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}