Please keep the following things in mind:
Please format code + Cypher statements with the code </>
icon, it's much easier to read.
Please provide the following information if you ran into a more serious issue:
- which OS do you use? use tags for that information
- neo4j version, desktop version, browser version
- what kind of API / driver do you use
- screenshot of [
PROFILE
or EXPLAIN
])
- a sample of the data you want to import
- which plugins / extensions / procedures do you use
- neo4j.log and debug.log
Windows 10
Desktop 4.5
neo4j.procedure.api-4.4.5
debug.log
Trying to import the Neo4j Example class Join.
I get the message on debug.log that the class could not be loaded due the "example/Join (wrong name: join)"
You forgot the body of your question.
Trying to import the Neo4j Example class Join.
I get the message on debug.log that the class could not be loaded due the "example/Join (wrong name: join)"
If you take the example code as is, you need to call the function example.join(). Its demonstrated in the included integration tests. If this does not work, can you provide your function definition code and your calling code?
I have used the code as is Created the jar and placed in the plugins folder.
This the error that is generated on the neo4j log file.
[o.n.k.a.p.GlobalProcedures]Failed to load 'Join' from plugin jar. '/plugins/example.jar' : example/Join (wrong name: Join)
Hum...I just created a new maven project, replaced the pom with what is provided in the example configuration (https://github.com/neo4j-examples/neo4j-procedure-template/blob/5.x/pom.xml), and copied the custom function code and test code into classes. The integration test is calling the custom function based on the custom function's package and method name. You either have to have the same package structure for the integration test to find the custom function, or name you custom function what you want and update the custom function with your name. You set the name of the custom function to other than the default by including a 'name' value in the UserFunction annotation. Using the annotation below, the custom function will be called as 'customFunction.join()'
@UserFunction(name = "customFunction.join")
I then packaged the code using 'mvn package' and moved the jar to my plug-in folder. It showed up in my list of functions and executed.
Do you want to paste you custom function code and integration test classes here? I can send you the IntelliJ project as well.
Sorry but I can' use MAVEN. I am building the jar in the command line.
This is my code:
package example;
import java.util.List;
import java.utl.*;
import org.neo4j.procedure.UserFunction;
import org.neo4j.procedure.Name;
import org.neo4j.procedure.Description;
public class Join
{
@UserFunction
public String join(
@Name("strings") List<String. strings,
@Name(value = "delimiter", defaultValue="'")String delimiter){
if (strings == null) || delimiter == null){
return null;
}
return String.join(delimiter, strings);
}
Compile the code with version 11.0.17 of java.
Generated the jar with MANIFEST file
Manifest-Version: 1.0
Created-By: User
Class-Path: ./neo4j-procedure-api-4.4.5.jar ./example.jar
Main-Class: ./Join
jar -cfm example.jar ./META=INF/MANIFEST.MF *.class neo4j-procedure-api-4.4.5.jar
The log file list the class not being loaded (example/Join (wrong name: Join)
I performed the following and it worked:
- compiled the code
- navigated to the target/classes folder the compiled classes are. mine contained a directory 'com' because my package is 'com.example.
- executed 'jar cvf join.jar com', this will create a jar with all the contents of 'com' folder. The Join.class file with the custom function is in the directory hierarchy.
- moved the jar to plug in folder.
Thanks,
Finally I got it to work. My problem was the way I compile and build the pkg.
1 Like