Search code examples
mavenneo4jcypherprocedureneo4jclient

There is no procedure with the name `example.convertDirection` registered for this database instance


I'm trying to create my own custom procedure using neo4J. I'm running the neo4j installer (v3.2.6) for windows. I followed this tutorial and created my own simple procedure below:

package example;
import java.util.List;

import org.neo4j.procedure.Description;
import org.neo4j.procedure.Name;
import org.neo4j.procedure.UserFunction;

public class ConvertDirection{

@UserFunction
@Description("example.convertDirection('v') - returns full direction name VERTICAL.")
public String convertDirection(
        @Name("string") String string) {
    if (string.equals(null)) {
        return null;
    }
    if(string.equalsIgnoreCase("v")){
        return "VERTICAL";
    } else if (string.equalsIgnoreCase("h")){
        return "HORIZONTAL";
    } else {
        return "BOTH";
    } 
}
}

I created my own test class and generated the jar running mvn clean package.

After that, I placed the procedure-template-1.0.0-SNAPSHOT in my both plugins folders (C:\Users\var\lib\neo4j\data\databases\graph.db\plugins and C:\Program Files\Neo4j CE 3.1.1\plugins).

Then I changed my neo4j.conf as suggested here to include the plugin paths. I've tried pointing both to program files/plugins and graph.db/plugins in both ways:

dbms.directories.plugins=c:/Users/var/lib/neo4j/data/databases/graph.db/plugins dbms.directories.plugins=c:/Program\ Files/Neo4j\ CE\ 3.1.1/plugins

After restarting the server, I still got this error and my procedure isn't listed.

There is no procedure with the name example.convertDirection registered for this database instance. Please ensure you've spelled the procedure name correctly and that the procedure is properly deployed.

Does anyone know what this might be?


Solution

  • You created a function, not a procedure (see @UserFunction in your code).

    You should see it listed in call dbms.functions(), and as a function, CALL and YIELD are not needed, just use it inline like any other function.