Search code examples
javadatabaseubuntutitanrexster

Verbose Rexster output/logging on error `null`


I use Titan in a small Ubuntu server cloud with size 3 and deployed a Rexster extension to to $TITAN_HOME/ext. However, if I try to call an endpoint of the extension I get

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

which is not very helpful. How can I get more verbose output to see what is going wrong here? In addition, error null seems strange to me. Any ideas what can cause it?

edit: I wrapped the whole execution of the extension that causes the errors in a try-catch-everything block:

@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());
    }
}

but keep getting

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

on client side. The rexstitan.log contains warnings concerning these errors:

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

which is nice to know but not very detailed.


Solution

  • You usually get that error if there is some failure during invocation of your extension. Usually, the console where Rexster is running should provide some log messages that explain the cause and have a stack trace.

    In the event that you are not seeing those for some reason, I would try to do your own logging in your extension and possibly trap exceptions in your code more generally (and logging in the catch clause) until you can see the error.