2
votes

I'm trying to create sample server plugin for Neo4j REST server based on http://docs.neo4j.org/chunked/snapshot/server-plugins.html

I put up Amazon EC2 instance with Neo4j 1.7.2 CE Ubuntu 12.04 64-bit (ami-f3c8679a) and it's working - I get proper response when trying to get MyEC2DNS:7474/db/data so server is OK.

In eclipse

  • created new Java project
  • created libs folder and copied all the files from the downloaded 1.7.2 Neo4j Community Edition - neo4j-community-1.7.2/lib and added them to build path
  • created sample class at package com.neo4j.server.plugins.example with the content

Code (from https://github.com/neo4j/community/blob/master/server-examples/src/main/java/org/neo4j/examples/server/plugins/GetAll.java)

@Description("An extension to the Neo4j Server for getting all nodes or relationships")
public class GetAll extends ServerPlugin {

    @Name("get_all_nodes")
    @Description("Get all nodes from the Neo4j graph database")
    @PluginTarget( GraphDatabaseService.class)
    public Iterable<Node> getAllNodes(@Source GraphDatabaseService graphDb) {
        return GlobalGraphOperations.at(graphDb).getAllNodes();
    }

    @Description("Get all relationships from the Neo4j graph database")
    @PluginTarget(GraphDatabaseService.class)
    public Iterable<Relationship> getAllRelationships(@Source GraphDatabaseService graphDb) {
        return GlobalGraphOperations.at(graphDb).getAllRelationships();
    }
}
  • in Eclipse created file org.neo4j.server.plugins.ServerPlugin inside META-INF/services with single line com.neo4j.server.plugins.example.GetAll
  • positioned in Java project folder and executed jar -cvf get_all.jar * - I got ~13Mb .jar file
  • copied it to my Amazon EC2 instance to /opt/neo4j/neo4j-community-1.7.2/plugins
  • restarted Neo4j server with sudo -u neo4j ./bin/neo4j restart
  • what I get is

Response

Stopping Neo4j server [1718].... done
./bin/neo4j: line 174: ulimit: open files: cannot modify limit: Operation not permitted
Starting Neo4j Server...WARNING: not chaning user
process [1891]... waiting for server to be ready...... OK

Still the extension is not visible when I GET MyEC2DNS:7474/db/data.

Ideas? My guess is that maybe this plugin is simply too large (there is no need to include all those .jars but what is the other way - to put them in relative paths, how?).

1
To verify, have you tried just putting the neo4j-server-examples.jar into the plugins folder and got it working? - Peter Neubauer

1 Answers

3
votes

Solved, all the steps are the same as in the question except

positioned in Java project folder and executed jar -cvf get_all.jar * - I got ~13Mb .jar file

which should be

- in Eclipse go to File - Export - JAR - export everything except 'lib' folder

Then it's working perfectly, and of course plugin itself is ~100 kB only.