spring-bootneo4jspring-data-neo4j-4neo4j-ogm

Why does Neo4j OGM with Spring Boot 2.0.0.M4 apparently require the embedded driver?


I have been trialling Spring Boot 2 (2.0.0.M4 at this stage) with the latest Spring Data Neo4j (currently 5.0.0.RC3) and can't seem to get it running.

I get the following error:

org.neo4j.ogm.exception.ConfigurationException: Could not load driver class org.neo4j.ogm.drivers.embedded.driver.EmbeddedDriver

I don't ask for an embedded driver, nor do I want one. I only want to use the bolt driver, which is already a dependency of spring-data-neo4j.

I've published a project to Github that was built using output from Spring Initializr that can be run to expose the error.

For reference, my build.gradle is as follows. Am I mis-configuring my project? Or is there something more serious wrong with the current Spring and Neo4j milestone builds?

buildscript {
    ext {
        springBootVersion = '2.0.0.M4'
    }
    repositories {
        mavenCentral()
        maven { url 'https://repo.spring.io/snapshot' }
        maven { url 'https://repo.spring.io/milestone' }
    }
    dependencies {
        classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}"
    }
}

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

version = "0.0.1-SNAPSHOT"

sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
    mavenLocal()
    mavenCentral()
    maven { url "https://repo.spring.io/snapshot" }
    maven { url "https://repo.spring.io/milestone" }
}

dependencies {
    compile "org.apache.tomcat.embed:tomcat-embed-jasper"
    compile "org.springframework.boot:spring-boot-starter-web"
    compile "org.springframework.boot:spring-boot-starter-data-neo4j"
    runtime "org.springframework.boot:spring-boot-devtools"
}

The rest of the code is available in Github as I mentioned earlier.


Solution

  • You don't have the embedded driver dependency anywhere, see

    ./gradlew dependencies
    

    output and search for neo4j-ogm.*driver - only neo4j-ogm-bolt driver is present. So if you want to use bolt only you have the dependencies set up correctly.

    The reason why you see this exception is because you configuration is wrong:

    return new SessionFactory("com.example.domain");
    

    This doesn't provide path to configuration file, the default then is impermanent embedded database, which needs the embedded driver - hence the exception.

    You have two options