【问题标题】:Install Neo4j REST server plugin安装 Neo4j REST 服务器插件
【发布时间】: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 上创建了包含内容的示例类

代码(来自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();
    }
}
  • 在 Eclipse 中创建文件 org.neo4j.server.plugins.ServerPluginMETA-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


【解决方案1】:

已解决,除

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

应该是

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

然后它工作得很好,当然插件本身只有~100 kB。

【讨论】:

    猜你喜欢
    • 2019-05-01
    • 1970-01-01
    • 2017-06-05
    • 1970-01-01
    • 2017-05-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多