Neo4j: How could I install APOC on Neo4j Server? - neo4j

I need to install APOC on Neo4j Server how could I do?
I created a folder "plugins" and after I executed the following command:
dbms.security.procedures.unrestricted=apoc.*
But I have this error:
Neo.ClientError.Statement.SyntaxError: Invalid input 'b': expected 'r/R' or
'e/E' (line 1, column 2 (offset: 1))
"dbms.security.procedures.unrestricted=apoc.*"^

Install the APOC jar from GitHub according to your Neo4j version by copying it to the plugins folder.
Add the property you mentioned, dbms.security.procedures.unrestricted=apoc.* to the end of your neo4j.conf file (located in the conf folder of your Neo4j installation.
The error you provided suggests you didn't add the property to the neo4j.conf file, but somehow entered it as a command in a Cypher query or something similar.

For anyone facing issues with restarting Neo4j instance after placing the apoc jar in the plugins folder: Latest version of the APOC jar doesn't work with all Neo4j installations. One needs to use the right APOC version.
For example, You can find the compatibility matrix for 3.2 version of Neo4j here: https://neo4j-contrib.github.io/neo4j-apoc-procedures/index32.html#_version_compatibility_matrix

Related

Neo4J crashes after installing APOC plugin

I'm trying to install the APOC Full jar file (4.2.0.6) to my Neo4J instance that's running in a Google Compute VM. To do so, I've installed the JAR file from GitHub releases to the /plugins folder. Each time I restart or run the environment it crashes with the following output to logs:
"Some jar procedure files (apoc-4.2.0.6-all.jar) are invalid, see log for details."
There's really no additional details provided...
If I copy the default APOC Core library found withing /labs, it works. I've tried to download this same file from Github and it fails. I've verified that the same user/group permissions are applied to the downloaded file as well.
Any ideas?
This usually happens for two reasons:
First is version mismatch. You can check which version you should use based on the version matrix, which is available at: https://github.com/neo4j-contrib/neo4j-apoc-procedures#version-compatibility-matrix. Unfortunately, it is not always up to date, but the APOC versions are if I understand correctly:
APOC 4.1.x.x -> Neo4j 4.1.x
APOC 4.2.x.x.-> Neo4j 4.2.x
APOC 4.3.x.x -> Neo4j 4.3.x
If I had to guess, you are probably using Neo4j 4.3 or 4.1 and using an APOC that is designed to work with Neo4j 4.2.
The other issue is that sometimes you have multiple APOC plugin files in the plugin folders, so that will also crash Neo4j.

Is apoc.rel.startNode removed from apoc 4.2.0.0?

I have neo4j 4.2.1 & apoc 4.2.0.0 installed on my mac. When I run the example on https://neo4j.com/labs/apoc/4.2/overview/apoc.rel/apoc.rel.startNode/ in neo4j desktop, I get the following error:
Unknown function 'apoc.rel.startNode' (line 4, column 8 (offset: 204))
"RETURN apoc.rel.startNode(rel) AS startNode"
I am able to successfully run the example on https://neo4j.com/labs/apoc/4.2/overview/apoc.rel/apoc.rel.type/
Does anyone know what is wrong? Thanks!
In 4.x, APOC core procs/functions are bundled with Neo4j and can be moved from the labs folder to the plugins folder for installation. It's possible that the function in question wasn't included in this core library.
You can look for and download the appropriate full version of APOC here, that will include functions and procedures beyond what is contained in the APOC core library.
https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases
Make sure you remove the existing jar when you add in the full jar, as if you try to start up with both in the plugins folder you'll encounter errors.

Neo4J 4 + Apoc : Unable to set up injection for procedure 'Static'

Getting the following error on neo4j server startup with the apoc plugin.
Have copied the jar to the plugins folder.
Caused by:
org.neo4j.kernel.api.exceptions.ComponentInjectionException: Unable to
set up injection for procedure 'Static', the field 'apocConfig' has
type 'class apoc.ApocConfig' which is not a known injectable component
Neo4j version: 4.0.4
Apoc version: 4.0.0.13
What could be the problem?
I would suggest reviewing the installation procedure to see if you missed any steps,
https://neo4j.com/docs/operations-manual/current/installation/linux/
Also, double check the java version that neo4j is using, and check if there are any other local java environment factors specific to this install. class paths, other jars, etc.
We were having the same issue with neo4j 4.x and custom plugin folder.
Updating custom plugin folder in neo4j config didn't work, we had to add folder (or extension) into java CP (classpath) as well.
It worked in 3.x neo4j version without adding a folder into the classpath.
Try to make sure that you have plugins folder listed in -cp and might work for you.
Similar to Ilija's problem, our embedded database (using Eclipse with the Maven plugin) did not like our custom plugin folder.
Since the database was for setup and then deployment (effectively 2 separate things), we could move the database from the default Neo4j directory after it was setup.
As a test, you could delete the contents of your plugin folder and see if it works then.

Error when tring to execute apoc.refactor.mergeNodes

I have neo4j version server 3.5.18 and I've installed apoc version 3.5.0.11. I think that I have correctly modified the conf file in this way
dbms.directories.plugins=/Users/lx2pwnd/Desktop/dev/neo4j-community-3.5.18/plugins
...
dbms.security.procedures.unrestricted=algo.*,apoc.*
...
dbms.security.procedures.whitelist=apoc.coll.*,apoc.load.*
But when I try to execute a query which contains CALL apoc.refactor.mergeNodes(..) i get this error:
There is no procedure with the name `apoc.refactor.mergeNodes` registered for this database instance. Please ensure you've spelled the procedure name correctly and that the procedure is properly deployed.
What's wrong ?
I believe the plugins path needs to be relative to the neo4j installation directory. This is safer, since different neo4j versions can be installed simultaneously, and they may need different plugin versions.
Try changing the dbms.directories.plugins value back to plugins, putting the APOC jar file in the existing plugins directory under your neo4j installation directory, and restarting neo4j.

NEO4J 3.1.1 Load CSV

I have been using Neo4j for several months now and am getting pretty exasperated.
It appears that every new version breaks the previous one.
I have multiple Cypher Load scripts that I can no longer run via the command line.
I can run the following from the Browser:
USING PERIODIC COMMIT 1000
LOAD CSV WITH HEADERS FROM "file:///person.csv" AS csvLine
MERGE (p:Person {sysurn : csvLine.urn})
ON CREATE SET p.dob = trim(csvLine.dob)
ON CREATE SET p.forename = trim(csvLine.forename)
ON CREATE SET p.surname = trim(csvLine.surname );
Previously in version 3.0.3 (Community Edition) I ran the following:
java -cp "C:\Program Files\Neo4j CE 3.0.3\bin\neo4j-desktop-3.0.3.jar" org.neo4j.shell.StartClient -file "D:/nosql/Load data/load_person.cql"
This no longer works in 3.1.1:
java -cp "C:\Program Files\Neo4j CE 3.1.1\bin\neo4j-desktop-3.1.1.jar" org.neo4j.shell.StartClient -file "D:/nosql/Load data/load_person.cql"
I get a Java Error. The general consensus is to run the full .tar version, so I installed that.
I can now run the Cypher from the browser or using cypher-shell. However this is of no use as there is no way to call an external script, so I have to do this for possibly hundreds of scripts.
Recommendation is to use ne04j-shell (now deprecated!)
I try neo4j-shell. This doesn't accept spaces in the path!
I move the file and try to run the following:
"C:\Program Files\neo4j-community-3.1.1\bin\neo4j-shell" -path "D:/nosql/neoDB/databases/graph.db" -config "neo4j.conf" -file "D:/nosql/Loaddata/load_person.cql"
I get the following error:
ERROR (-v for expanded information):
Error starting org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory,
D:\nosql\neoDB\databases\graph.db
I have tried various combinations including adding the host name as prompted:
non-JRMP server at remote endpoint
I try adding the -config param, however this again doesn't allow spaces!
With every new version it seems to get more difficult to actually import data into Neo4j.
My question is, Is it possible in version 3.1.1 to run more than one cypher script at a time without manually running every one?
Is it possible to use neo4j-shell in version 3.1.1?
Try using the APOC procedure apoc.cypher.runFile from within cypher-shell. Here is an example (with a file URL formatted for Windows):
CALL apoc.cypher.runFile("file:d:/nosql/Load data/load_person.cql");
If the space in the path still presents problems, you could rename the "Load data" folder to "LoadData" and modify the above query accordingly.
Well I have managed to find a workaround.
Install neo4j 3.1.1
Create a database
Uninstall Neo4j
Install neo4j 3.0.8
Run my Cypher scripts
e.g. java -cp "C:\Program Files\Neo4j CE
3.0.8\bin\neo4j-desktop-3.0.8.jar" org.neo4j.shell.StartClient -file "D:/nosql/Load data/load_person.cql"
uninstall neo4j
install neo4j 3.1.1
I don't think this is going to cut it in a production environment though :)

Resources