I have generated a new quarkus project (v3.17.7) using gradle with kotlin and added the:
implementation("org.neo4j:neo4j-ogm-quarkus:3.11.0")
dependency.
The app doesn't start when the neo4j-ogm-quarkus dependency is present. I let quarkus build a neo4j db docker image for me, I also tried with my own neo4j db (v4.3.3 and v5.26.1). I also tried using quarkus (v3.17.3 and v3.15.3) and neo4j-ogm-quarkus:3.9.0.
My error looks like this:
2025-01-27 09:23:41,492 ERROR [io.qua.run.Application] (Quarkus Main Thread) Failed to start application: java.lang.RuntimeException: Failed to start quarkus
at io.quarkus.runner.ApplicationImpl.doStart(Unknown Source)
at io.quarkus.runtime.Application.start(Application.java:101)
at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:119)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:71)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:44)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:124)
at io.quarkus.runner.GeneratedMain.main(Unknown Source)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:569)
at io.quarkus.runner.bootstrap.StartupActionImpl$1.run(StartupActionImpl.java:116)
at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: java.lang.NoClassDefFoundError: io/micrometer/context/ContextSnapshotFactory
at java.base/java.lang.Class.getDeclaredFields0(Native Method)
at java.base/java.lang.Class.privateGetDeclaredFields(Class.java:3297)
at java.base/java.lang.Class.getDeclaredFields(Class.java:2371)
at org.neo4j.ogm.metadata.FieldsInfo.<init>(FieldsInfo.java:57)
at org.neo4j.ogm.metadata.ClassInfo.<init>(ClassInfo.java:139)
at org.neo4j.ogm.metadata.ClassInfo.<init>(ClassInfo.java:119)
at org.neo4j.ogm.metadata.DomainInfo.lambda$addClass$2(DomainInfo.java:172)
at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1220)
at org.neo4j.ogm.metadata.DomainInfo.addClass(DomainInfo.java:172)
at org.neo4j.ogm.metadata.DomainInfo.create(DomainInfo.java:98)
at org.neo4j.ogm.metadata.MetaData.<init>(MetaData.java:66)
at org.neo4j.ogm.session.SessionFactory.<init>(SessionFactory.java:124)
at org.neo4j.ogm.session.SessionFactory.<init>(SessionFactory.java:110)
at org.neo4j.ogm.quarkus.runtime.Neo4jOgmRecorder.initializeSessionFactory(Neo4jOgmRecorder.java:65)
at io.quarkus.deployment.steps.Neo4jOgmProcessor$createSessionFactory1383093778.deploy_0(Unknown Source)
at io.quarkus.deployment.steps.Neo4jOgmProcessor$createSessionFactory1383093778.deploy(Unknown Source)
... 13 more
Caused by: java.lang.ClassNotFoundException: io.micrometer.context.ContextSnapshotFactory
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:565)
at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:513)
... 29 more
2025-01-27 09:23:41,492 ERROR [io.qua.run.Application] (Quarkus Main Thread) Failed to start application: java.lang.RuntimeException: Failed to start quarkus
at io.quarkus.runner.ApplicationImpl.doStart(Unknown Source)
at io.quarkus.runtime.Application.start(Application.java:101)
at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:119)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:71)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:44)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:124)
at io.quarkus.runner.GeneratedMain.main(Unknown Source)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:569)
at io.quarkus.runner.bootstrap.StartupActionImpl$1.run(StartupActionImpl.java:116)
at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: java.lang.NoClassDefFoundError: io/micrometer/context/ContextSnapshotFactory
at java.base/java.lang.Class.getDeclaredFields0(Native Method)
at java.base/java.lang.Class.privateGetDeclaredFields(Class.java:3297)
at java.base/java.lang.Class.getDeclaredFields(Class.java:2371)
at org.neo4j.ogm.metadata.FieldsInfo.<init>(FieldsInfo.java:57)
at org.neo4j.ogm.metadata.ClassInfo.<init>(ClassInfo.java:139)
at org.neo4j.ogm.metadata.ClassInfo.<init>(ClassInfo.java:119)
at org.neo4j.ogm.metadata.DomainInfo.lambda$addClass$2(DomainInfo.java:172)
at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1220)
at org.neo4j.ogm.metadata.DomainInfo.addClass(DomainInfo.java:172)
at org.neo4j.ogm.metadata.DomainInfo.create(DomainInfo.java:98)
at org.neo4j.ogm.metadata.MetaData.<init>(MetaData.java:66)
at org.neo4j.ogm.session.SessionFactory.<init>(SessionFactory.java:124)
at org.neo4j.ogm.session.SessionFactory.<init>(SessionFactory.java:110)
at org.neo4j.ogm.quarkus.runtime.Neo4jOgmRecorder.initializeSessionFactory(Neo4jOgmRecorder.java:65)
at io.quarkus.deployment.steps.Neo4jOgmProcessor$createSessionFactory1383093778.deploy_0(Unknown Source)
at io.quarkus.deployment.steps.Neo4jOgmProcessor$createSessionFactory1383093778.deploy(Unknown Source)
... 13 more
Caused by: java.lang.ClassNotFoundException: io.micrometer.context.ContextSnapshotFactory
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:565)
at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:513)
... 29 more
the dependencies in my build.gradle.kts look like this:
dependencies {
implementation(enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}"))
implementation("io.quarkus:quarkus-arc")
implementation("io.quarkus:quarkus-rest")
implementation("io.quarkus:quarkus-config-yaml")
implementation("io.quarkus:quarkus-rest-jackson")
implementation("io.quarkus:quarkus-smallrye-health")
// Quarkus Neo4j Extension
// implementation("io.quarkiverse.neo4j:quarkus-neo4j:5.0.3")
// implementation("io.micrometer:context-propagation:1.1.2")
// implementation("org.conscrypt:conscrypt-openjdk:2.5.2")
implementation("org.neo4j:neo4j-ogm-quarkus:3.11.0")
// Lombok
compileOnly("org.projectlombok:lombok:1.18.36")
annotationProcessor("org.projectlombok:lombok:1.18.36")
// MapStruct
implementation("org.mapstruct:mapstruct:1.6.3")
annotationProcessor("org.mapstruct:mapstruct-processor:1.6.3")
// Test frameworks
testImplementation("io.quarkus:quarkus-junit5")
testImplementation("io.rest-assured:rest-assured")
}
Steps to reproduce: generate a quarkus project and add neo4j-ogm-quarkus dependency.
it seems that Quarkus or $something in the middle of the stack has (again) become much more eager when scanning things. I am the author of both neo4j-ogm-quarkus and quarkus-neo4j and will investigate this. In the meantime, please use org.neo4j.ogm.base-packages
to configure the packages that OGM will take into account while scanning for annotated classes. i.e.
org.neo4j.ogm.base-packages=org.acme
will fix this.