问题
Following the instruction on the neo4j website for building a server extension, i cannot get the plugin to show in the list of available extensions.
This is the content of my jar which i placed in the plugins directory of neo4j:
META-INF/MANIFEST.MF
META-INF/
META-INF/services/
META-INF/services/org.neo4j.server.plugins.ServerPlugin
example/
example/GetAll.class
example/GetAll.java
The file org.neo4j.server.plugins.ServerPlugin contains the string example.GetAll. The code for GetAll.java was taken directly from the Neo4j website (see below). Any help would be much appreciated.
Neo4j verison: 2.1.3 (installed with Homebrew on OSX - 10.8.5)
code:
package example;
import java.util.ArrayList;
import java.util.List;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Relationship;
import org.neo4j.graphdb.Transaction;
import org.neo4j.server.plugins.Description;
import org.neo4j.server.plugins.Name;
import org.neo4j.server.plugins.PluginTarget;
import org.neo4j.server.plugins.ServerPlugin;
import org.neo4j.server.plugins.Source;
import org.neo4j.tooling.GlobalGraphOperations;
@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 )
{
ArrayList<Node> nodes = new ArrayList<>();
try (Transaction tx = graphDb.beginTx())
{
for ( Node node : GlobalGraphOperations.at( graphDb ).getAllNodes() )
{
nodes.add( node );
}
tx.success();
}
return nodes;
}
@Description( "Get all relationships from the Neo4j graph database" )
@PluginTarget( GraphDatabaseService.class )
public Iterable<Relationship> getAllRelationships( @Source GraphDatabaseService graphDb )
{
List<Relationship> rels = new ArrayList<>();
try (Transaction tx = graphDb.beginTx())
{
for ( Relationship rel : GlobalGraphOperations.at( graphDb ).getAllRelationships() )
{
rels.add( rel );
}
tx.success();
}
return rels;
}
}
log entries from starting the server - console.log:
2014-08-09 13:46:27.743+0000 INFO [API] Setting startup timeout to: 120000ms based on -1
2014-08-09 13:46:28.869+0000 INFO [API] Successfully started database
2014-08-09 13:46:28.925+0000 INFO [API] Starting HTTP on port :7474 with 80 threads available
2014-08-09 13:46:29.097+0000 INFO [API] Enabling HTTPS on port :7473
2014-08-09 13:46:29.184+0000 INFO [API] Mounted discovery module at [/]
2014-08-09 13:46:29.192+0000 INFO [API] Mounted REST API at [/db/data/]
2014-08-09 13:46:29.195+0000 INFO [API] Mounted management API at [/db/manage/]
2014-08-09 13:46:29.195+0000 INFO [API] Mounted webadmin at [/webadmin]
2014-08-09 13:46:29.195+0000 INFO [API] Mounted Neo4j Browser at [/browser]
2014-08-09 13:46:29.247+0000 INFO [API] Mounting static content at [/webadmin] from [webadmin-html]
2014-08-09 13:46:29.292+0000 INFO [API] Mounting static content at [/browser] from [browser]
14:46:29.295 [main] WARN o.e.j.server.handler.ContextHandler - o.e.j.s.ServletContextHandler@40e74e3{/,null,null} contextPath ends with /
14:46:29.295 [main] WARN o.e.j.server.handler.ContextHandler - Empty contextPath
14:46:29.298 [main] INFO org.eclipse.jetty.server.Server - jetty-9.0.5.v20130815
14:46:29.324 [main] INFO o.e.j.server.handler.ContextHandler - Started o.e.j.s.h.MovedContextHandler@3d8c2eeb{/,null,AVAILABLE}
14:46:29.409 [main] INFO o.e.j.w.StandardDescriptorProcessor - NO JSP Support for /webadmin, did not find org.apache.jasper.servlet.JspServlet
14:46:29.419 [main] INFO o.e.j.server.handler.ContextHandler - Started o.e.j.w.WebAppContext@24c32994{/webadmin,jar:file:/usr/local/Cellar/neo4j/2.1.3/libexec/system/lib/neo4j-server-2.1.3-static-web.jar!/webadmin-html,AVAILABLE}
14:46:29.810 [main] INFO o.e.j.server.handler.ContextHandler - Started o.e.j.s.ServletContextHandler@3582d322{/db/manage,null,AVAILABLE}
14:46:30.054 [main] INFO o.e.j.server.handler.ContextHandler - Started o.e.j.s.ServletContextHandler@558d60a3{/db/data,null,AVAILABLE}
14:46:30.072 [main] INFO o.e.j.w.StandardDescriptorProcessor - NO JSP Support for /browser, did not find org.apache.jasper.servlet.JspServlet
14:46:30.073 [main] INFO o.e.j.server.handler.ContextHandler - Started o.e.j.w.WebAppContext@7aa6ede2{/browser,jar:file:/usr/local/Cellar/neo4j/2.1.3/libexec/system/lib/neo4j-browser-2.1.3.jar!/browser,AVAILABLE}
14:46:30.155 [main] INFO o.e.j.server.handler.ContextHandler - Started o.e.j.s.ServletContextHandler@40e74e3{/,null,AVAILABLE}
14:46:30.164 [main] INFO o.e.jetty.server.ServerConnector - Started ServerConnector@2e85a1ef{HTTP/1.1}{localhost:7474}
14:46:30.520 [main] INFO o.e.jetty.server.ServerConnector - Started ServerConnector@d4a4b67{SSL-HTTP/1.1}{localhost:7473}
2014-08-09 13:46:30.520+0000 INFO [API] Server started on: http://localhost:7474/
2014-08-09 13:46:30.521+0000 INFO [API] Remote interface ready and available at [http://localhost:7474/]
neo4j.0.0.log:
Aug 09, 2014 2:49:59 PM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
INFO: Initiating Jersey application, version 'Jersey: 1.9 09/02/2011 11:17 AM'
Aug 09, 2014 2:50:00 PM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
INFO: Initiating Jersey application, version 'Jersey: 1.9 09/02/2011 11:17 AM'
Aug 09, 2014 2:50:00 PM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
INFO: Initiating Jersey application, version 'Jersey: 1.9 09/02/2011 11:17 AM'
来源:https://stackoverflow.com/questions/25218412/neo4j-server-plugin-plugin-does-not-show-up-in-extensions