【问题标题】:Verbose Rexster output/logging on error `null`详细的 Rexster 输出/记录错误`null`
【发布时间】:2015-03-18 13:13:37
【问题描述】:

我在大小为 3 的小型 Ubuntu 服务器云中使用 Titan,并将 Rexster 扩展部署到 $TITAN_HOME/ext。但是,如果我尝试调用我得到的扩展的端点

{"message":"An error occurred while generating the response object","error":null}

这不是很有帮助。如何获得更详细的输出以查看这里出了什么问题?此外,错误null 对我来说似乎很奇怪。有什么想法会导致它吗?

编辑: 我将导致错误的扩展的整个执行包装在一个 try-catch-everything 块中:

@ExtensionNaming(
    namespace = GraphityExtension.EXT_NAMESPACE,
    name = "unfollow")
public class RemoveFollowshipExtension extends GraphityExtension {

@ExtensionDefinition(
        extensionPoint = ExtensionPoint.GRAPH)
@ExtensionDescriptor(
        description = "Removes a followship between two users.")
public
    ExtensionResponse
    unfollow(
            @RexsterContext RexsterResourceContext content,
            @RexsterContext Graph graph,
            @ExtensionRequestParameter(
                    name = "following",
                    description = "identifier of the user following") String idFollowing,
            @ExtensionRequestParameter(
                    name = "followed",
                    description = "identifier of the user followed") String idFollowed) {
    try {
        Graphity graphity = getGraphityInstance((TitanGraph) graph);
        Map<String, String> map = new HashMap<String, String>();
        try {
            map.put(KEY_RESPONSE_VALUE, String.valueOf(graphity
                    .removeFollowship(idFollowing, idFollowed)));
            return ExtensionResponse.ok(new JSONObject(map));
        } catch (UnknownFollowingIdException | UnknownFollowedIdException e) {
            return ExtensionResponse.error(e);
        }
    } catch (Exception e) {
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        e.printStackTrace(pw);
        return ExtensionResponse.error(sw.toString());
    }
}

但不断得到

{"message":"","error":null}

在客户端。 rexstitan.log 包含有关这些错误的警告:

com.tinkerpop.rexster.GraphResource  - The [graphity:unfollow+*] extension raised an error response.

很高兴知道,但不是很详细。

【问题讨论】:

    标签: java database ubuntu titan rexster


    【解决方案1】:

    如果在调用您的扩展程序期间出现一些故障,您通常会收到该错误。通常,运行 Rexster 的控制台应该提供一些日志消息来解释原因并具有堆栈跟踪。

    如果您由于某种原因没有看到这些,我会尝试在您的扩展程序中进行自己的日志记录,并可能更普遍地在您的代码中捕获异常(并记录在 catch 子句中),直到您看到错误.

    【讨论】:

    • 我将整个执行过程包装在一个 try-catch-everything 块中,但没有成功。有关详细信息,请参阅编辑后的答案。
    • 目前,与其尝试在响应中将错误返回为 JSON,不如使用记录器实例,就像在一些打包的 Rexster Kibbles 中所做的那样:github.com/tinkerpop/rexster/blob/… - i'我只是想看看错误首先出现在哪里。
    • 记录错误比ErrorResponses 给了我更多有用的信息,谢谢!
    猜你喜欢
    • 2016-01-09
    • 1970-01-01
    • 2013-04-02
    • 2012-04-06
    • 2011-05-25
    • 2023-03-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多