Issue with using neo4j OGM embedded driver

I am having issues using the embedded driver with neo4j OGM for testing. I set up my SessionFactory like this:
image

but when I run my tests I get this error:

java.lang.NoClassDefFoundError: org/neo4j/graphdb/factory/GraphDatabaseFactory
at org.neo4j.ogm.drivers.embedded.driver.EmbeddedDriver.getGraphDatabaseFactory(EmbeddedDriver.java:143)
at org.neo4j.ogm.drivers.embedded.driver.EmbeddedDriver.configure(EmbeddedDriver.java:116)
at org.neo4j.ogm.session.SessionFactory.newConfiguredDriverInstance(SessionFactory.java:268)
at org.neo4j.ogm.session.SessionFactory.(SessionFactory.java:89)

I am using neo4j OGM version 3.2.32 and neo4j version 4.1.0, the strange thing is if I revert my neo4j version to 3.5 it works fine. Here is my pom just for reference:

I would like to use neo4j version 4.1 and the documentation says that neo4j OGM should support up to 4.1: Reference - OGM Library

If anyone has any ideas on how to fix it it would be greatly appreciated. Thanks.

Please read the linked compatibility matrix carefully. It points out:

2 These versions are only supported over Bolt.

Meaning that you have to pull in the 4.x dependencies manually (without depending on Neo4j-OGM's embedded driver) and start the embedded instance with Bolt enabled. Your connection should then be also based on Bolt.

As an alternative solution, you could also go with the Neo4j Testcontainers and connect to it as it where just another server. It is most of the time the better alternative than creating a local stack for testing manually.

1 Like