【发布时间】:2012-09-08 10:18:53
【问题描述】:
我正在尝试为基于 http://docs.neo4j.org/chunked/snapshot/server-plugins.html 的 Neo4j REST 服务器创建示例服务器插件
我使用 Neo4j 1.7.2 CE Ubuntu 12.04 64-bit (ami-f3c8679a) 建立了 Amazon EC2 实例,它正在工作 - 我在尝试获取 MyEC2DNS:7474/db/data 时得到了正确的响应,因此服务器正常。
在日食中
- 创建了新的 Java 项目
- 创建
libs文件夹并从下载的1.7.2 Neo4j Community Edition-neo4j-community-1.7.2/lib复制所有文件并将它们添加到构建路径 - 在
package com.neo4j.server.plugins.example上创建了包含内容的示例类
@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();
}
}
- 在 Eclipse 中创建文件
org.neo4j.server.plugins.ServerPlugin在META-INF/services内,单行com.neo4j.server.plugins.example.GetAll - 位于 Java 项目文件夹中并执行
jar -cvf get_all.jar *- 我得到了 ~13Mb .jar 文件 - 将它复制到我的 Amazon EC2 实例到
/opt/neo4j/neo4j-community-1.7.2/plugins - 使用
sudo -u neo4j ./bin/neo4j restart重新启动 Neo4j 服务器 - 我得到的是
回应
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
当我 GET MyEC2DNS:7474/db/data 时,扩展仍然不可见。
想法?我的猜测是,也许这个插件太大了(没有必要包含所有这些 .jar,但另一种方法是 - 将它们放在相对路径中,如何?)。
【问题讨论】:
-
为了验证,您是否尝试过将 neo4j-server-examples.jar 放入插件文件夹并使其正常工作?
标签: java rest plugins amazon-ec2 neo4j