bobbydev
bobbydev

Reputation: 525

Writing a simple Neo4j server - getting runtime error

I am a complete newbie to Neo4j. I am trying to write a simple Neo4j server that would listen on a port of my choice. The code I am using is exactly the same as in the file server.java at the following tutorial http://hmkcode.com/first-time-neo4j/ The code compiles fine but when I try to run it I get an error (pasted below) Any help would be appreciated. I am using jre7 and jdk1.8.0_11

For your convenience I have also cut and pasted the code below (exactly the same as in the above link)

   import org.neo4j.graphdb.factory.GraphDatabaseFactory;

   import org.neo4j.graphdb.factory.GraphDatabaseSetting;

   import org.neo4j.kernel.GraphDatabaseAPI;

   import org.neo4j.server.WrappingNeoServerBootstrapper;

   import org.neo4j.server.configuration.Configurator;

   import org.neo4j.server.configuration.ServerConfigurator;

   import org.neo4j.shell.ShellSettings;

public class neoserver {

    public static void main(String args[]){
        {
                GraphDatabaseAPI graphdb = (GraphDatabaseAPI) new GraphDatabaseFactory()
                .newEmbeddedDatabaseBuilder( "db/graphDB" )
                .setConfig( ShellSettings.remote_shell_enabled, GraphDatabaseSetting.TRUE )
                .newGraphDatabase();
                ServerConfigurator config;
                config = new ServerConfigurator( graphdb );
                // let the server endpoint be on a custom port
                config.configuration().setProperty(Configurator.WEBSERVER_PORT_PROPERTY_KEY, 7575 );

                WrappingNeoServerBootstrapper srv;
                srv = new WrappingNeoServerBootstrapper( graphdb, config );
                srv.start();
            }
        } 
    }

ERROR that I get

   Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lang/text/StrLookup

   at org.neo4j.server.configuration.ServerConfigurator.<init>(ServerConfigurator.java:52)

   at jungpagerankserver.neoserver.main(neoserver.java:80)

   Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang.text.StrLookup

   at java.net.URLClassLoader$1.run(URLClassLoader.java:372)

   at java.net.URLClassLoader$1.run(URLClassLoader.java:361)

   at java.security.AccessController.doPrivileged(Native Method)

   at java.net.URLClassLoader.findClass(URLClassLoader.java:360)

   at java.lang.ClassLoader.loadClass(ClassLoader.java:424)

   at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)

   at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

   ... 2 more

Upvotes: 1

Views: 488

Answers (1)

Stefan Armbruster
Stefan Armbruster

Reputation: 39925

The tutorial you're referencing seems to use Eclipse and not a dedicated build system. Every serious project should not rely on and IDE for building, instead a tool like Maven or Gradle are a good choice.

Make sure you have all transitive dependencies of neo4j-server on your classpath. When using maven, add to your pom.xml with the dependencies section:

<dependency>
    <groupId>org.neo4j.app</groupId>
    <artifactId>neo4j-server</artifactId>
    <version>2.1.3</version>
</dependency>

In case of gradle, use inside dependencies:

compile 'org.neo4j.app:neo4j-server:2.1.3'

Upvotes: 1

Related Questions