Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
11-26-2018 01:05 PM
Hello everyone.
I have a Java app working with Neo4j and APOC.
I'm facing a problem calling an APOC function from java, which is apoc.text.join.
When I run a Cypher query I got this error:
org.neo4j.cypher.SyntaxException: Unknown function 'apoc.text.join'
My register function is:
private static void registerApocProcedure(GraphDatabaseService graphDB) throws IllegalArgumentException {
//Register APOC procedures
Procedures procedures = ((GraphDatabaseAPI) graphDB).getDependencyResolver().resolveDependency(Procedures.class);
List<Class<?>> apocProcedures = Arrays.asList(Xml.class, GraphRefactoring.class, apoc.text.Strings.class);
apocProcedures.forEach((proc) -> {
try {
procedures.registerProcedure(proc);
} catch (KernelException e) {
throw new RuntimeException("Error registering "+proc,e);
}
});
}
I recently added apoc.text.Strings.class where it's supposed to be the Join function, but it doesn't work.
I also tried to install Neo4j with APOC plugin and run the embedded browser, the same queries with apoc.text.join work fine!
Calling: CALL apoc.help('apoc.text.join'), apoc.text.join is marked as a function.
So, is the way of calling a APOC function in Java different?
Am I doing something wrong?
Many thanks!
Solved! Go to Solution.
11-27-2018 01:53 PM
You also have to call procedures.registerFunction(proc)
with each class.
11-27-2018 01:53 PM
You also have to call procedures.registerFunction(proc)
with each class.
06-19-2019 05:09 AM
Can any one help how can we call the predefined apoc from java application. I am creating my own apoc in which i want to call apoc.load.jdbc. How can i do that
06-19-2019 03:07 PM
The same way you call other cypher statements. With db.execute(statement, params)
in the Java API of the injected graph database service.
06-20-2019 08:23 AM
Thank Michael. Do I need to register the procedure before the executing ?
I made below custom procedure for just to test
public Stream loadPlan(@Name(value="planCode")String planCode){
String str="This is the plan"+planCode;
List<String> alpha = Arrays.asList(str);
return alpha.stream().map(planName-> new PlanDTO(str));
//return str.chars().mapToObj();
}
now I want to test this apoc via another Java class .
06-24-2019 09:42 AM
will this syntax can be used to run function from java class also ???
db.execute(statement, params)
All the sessions of the conference are now available online