paulB
(Paul Bazin)
March 18, 2022, 11:30am
1
Hello,
Currently working with Spring Data Neo4j, I'm using neo4j in 4.4.4.
I need to use an apoc coll function in a test. As this function is not bring by a simple import, I need to import in my pom.xml apoc with classifier all :
<dependency>
<groupId>org.neo4j.procedure</groupId>
<artifactId>apoc</artifactId>
<version>4.4.0.3</version>
<scope>test</scope>
<classifier>all</classifier>
</dependency>
But this bring an old version of neo4j Driver (4.0.0) witch create conflict and result in unexecutable query.
It seem that this old version of neo4j is used for all latest apoc version.
Is there any chance for this to be updated?
Is there any way of getting only procedure and function class from the repository?
In advance thank you for your help.
paulB
(Paul Bazin)
March 21, 2022, 8:37am
2
This problem will be solve soon. See the question here on the projects github :
opened 10:24AM - 04 Mar 22 UTC
closed 04:59PM - 31 Aug 22 UTC
# Situation
We have a Java application that works with Neo4j (version `4.4`). T… he application connects to Neo4j via Bolt using Neo4j Java driver.
For unit tests we tear up Neo4j inside the same JVM using the [Neo4j harness](https://github.com/neo4j/neo4j/tree/4.4/community/neo4j-harness), expose the bolt port and connect from the application via Bolt. As we are using APOC procedures, we also need to put APOC on the classpath.
So overall the classpath contains:
- Neo4j 4.4 (Enterprise)
- Neo4j Java Driver 4.4.3
- APOC 4.4.0.3
- Our application
- Our application's dependencies
To add APOC to our application, from my understanding of the [official documentation](https://neo4j.com/labs/apoc/4.4/introduction) there are two options:
- APOC Core: `[...] battle hardened procedures and functions that don’t have external dependencies [...]` -> this doesn't seem correct, as it has lots of external dependencies which are shaded into on fat jar
- APOC Full: `[...] additional procedures and functions [...]`
Looking at the [Github releases](https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases), I find the download links for both. The jars are huge, containing shaded versions of all external dependencies of APOC.
Looking at [Maven Central](https://search.maven.org/artifact/org.neo4j.procedure/apoc/4.4.0.3/jar), I find a version with classifier `all` that appears to be the same as APOC Full and a version without classifier that seems to have the same dependencies as APOC Core (but not shaded) but doesn't have the feature set of APOC core.
# Problem Description
There are multiple issues:
1. Having `APOC Full 4.4.0.3` and `Neo4j Java Driver 4.4.3` on the classpath doesn't work as APOC brings a shaded version of the old `Neo4j Java Driver 4.0.0` which is not API compatible.
2. For our use case `APOC Core 4.4.0.3` would be fine which doesn't contain a shaded Neo4j Java driver but it is not available on a public maven repository.
3. We could work around issue 2. by uploading APOC Core to our internal Maven repository but that still leaves lots of other shaded dependencies inside APOC core which may lead to side effects with dependencies of our application. Therefor I'd prefer to use a version of APOC Core that does not contain shaded dependencies, so I have full control of everything (knowing that APOC functionality may break if I override dependency versions).
# Questions / Remarks / Suggestions
1. Please explain the focus/scope of the apoc jar (without classifier) on Maven Central.
2. Is it possible to publish apoc-core to Maven Central as a short term solution?
3. Is it possible to publish a version of apoc-core to Maven Central that does not contain any shaded dependencies?
4. Is there a reason for not upgrading the Neo4j Java Driver in APOC?
5. In the long term it probably would be good to add a prefix to the java package names of shaded dependencies. Lots of other libraries are doing this (e.g, neo4j-logging with Log4j).
# Further Notes
I am aware that using [test containers](https://www.testcontainers.org/modules/databases/neo4j/) instead of the `Neo4j harness` would solve the issue as APOC could be put into the Neo4j container, however that makes the development, testing and debugging process slower so we don't want to use this as the default.
The issue was already discussed in a couple of related issues without solution:
- #1656 ends with the note `We'll add a test-harness example soon.` -> this would be pretty much what I described here and it currently won't work
- #1825 mentioned that there is only the 'small' apoc jar on Maven Central but in the fix only apoc-full but not apoc-core was added
- neo4j/neo4j#12575 was also about the issue that apoc from Maven Central does not contain the core procedures. No real solution for Maven was created but only a Gradle solution that downloads the dependency directly from APOC's GitHub releases during build.