I'm developing an app using Neo4j 3.5.14 database and Neo4j-OGM. Whilst developing the POC i hand crafted the CRUD operations using Cypher and the java driver 1.7.5. It worked fine. Now as we move to formalising the app we want to exploit Neo4j-ogm.
The Maven based dependencies we have created for the project are as below.
Very early in the app execution we are getting this exception (see below) being thrown from deep inside the driver. Any bright ideas about the cause of this ??
This looks like a classpath problem coming from a duplicated java driver dependency in different versions.
As you can see in the exception log there are some internal calls going on in the driver. From the changes in the driver, I can see that the method was introduced in the 4.0 version and is not available in the 1.7 line of the driver.
The list in eclipse looks pretty ok, so I would suggest doing a mvn dependency:tree on your project and looking at the neo4j-java-driver versions.
Firstly - many thanks for your swift response - really appreciated.
I have run an mvn dependency tree against the project and i do NOT see a smoking gun.
The output is attached. as you can see the only neo4j-java-driver is 4.0.1.
Hi, well I think i found part of the problem - the project had a dependant project in the build path andthat dependant project was built with 1.7.5.
I've cleaned that up and observed that maven is no longer trying to drag 1.7.5 into the local repo.
there is still a problem in the same area of code though the exception has now changed to "ExceptionInInitializerError".
Of course setting up the SessionFactory via the Configuration based constructor is just 1 possibility - i could try the existing Driver route - however i run into a different problem there.
If I make the Driver of type org.neo4j.ogm.driver.Driver then the construction of the sessionFactory is happy but the initialisation of the Driver is not happy.
Casting between the 2 types of driver is not possible. The ogm documentation implies that i should be able to construct using the existing driver (i.e org.neo4j.driver.Driver) but I cannot seem to find that overloaded version of the constructor.
So i am in a bit of a double bind and any suggestions would be gratefully received
Hi Gerrit, ignore my earlier posts. I have done some more digging and can now identify what i think is the root cause. In summary your earlier observation re conflicting multiple drivers (1.7.5 & 4.0.1) was spot on - many thanks. Unfortunately that revealed another exception - ExceptionIninitial…
You are accessing Neo4JSessionFactory#createNeo4JSession before it was completely initialized.
Starting with the new SessionFactory in this class, Neo4j-OGM begins to scan for entities and encounters Class2 with the static field of type DomainmodelFactory and its initialization call.
The DomainmodelFactory needs the Session mySession field that gets set via Neo4JSessionFactory.createNeo4JSession(). This access returns null because the initialization process is not yet completed. Your code is still in the first step and as a consequence the graphSessionFactory in Neo4JSessionFactory is not yet set.
To solve this, you should really avoid using all those static references in your code.