neo4j / graph-data-science

Source code for the Neo4j Graph Data Science library of graph algorithms.
https://neo4j.com/docs/graph-data-science/current/
Other
596 stars 157 forks source link

java.lang.ClassNotFoundException: org.neo4j.test.TestDatabaseManagementServiceBuilder #297

Closed icejean closed 4 months ago

icejean commented 5 months ago

Hi, all, I'm building my own algorithms on the base of Neo4j Community+ Open GDS, and have successfully tested them with Neo4j Community 5.10.0+ Open GDS 2.5.5, with a workaround of issue#294, but when I update my Eclipse Maven project to the latest Neo4j Community 5.16.0+ Open GDS 2.5.7, I get the exceptions while trying to run Junit test of algorithm procedures, org.neo4j.gds.paths.spanningtree.SpanningTreeWriteProcTest.java for example.

org.junit.platform.commons.JUnitException: TestEngine with ID 'jqwik' failed to discover tests
    at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverEngineRoot(EngineDiscoveryOrchestrator.java:160)
    at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverSafely(EngineDiscoveryOrchestrator.java:132)
    at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discover(EngineDiscoveryOrchestrator.java:107)
    at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discover(EngineDiscoveryOrchestrator.java:78)
    at org.junit.platform.launcher.core.DefaultLauncher.discover(DefaultLauncher.java:99)
    at org.junit.platform.launcher.core.DefaultLauncher.discover(DefaultLauncher.java:77)
    at org.junit.platform.launcher.core.DelegatingLauncher.discover(DelegatingLauncher.java:42)
    at org.junit.platform.launcher.core.SessionPerRequestLauncher.discover(SessionPerRequestLauncher.java:56)
    at org.eclipse.jdt.internal.junit5.runner.JUnit5TestReference.<init>(JUnit5TestReference.java:46)
    at org.eclipse.jdt.internal.junit5.runner.JUnit5TestLoader.createUnfilteredTest(JUnit5TestLoader.java:88)
    at org.eclipse.jdt.internal.junit5.runner.JUnit5TestLoader.createTest(JUnit5TestLoader.java:69)
    at org.eclipse.jdt.internal.junit5.runner.JUnit5TestLoader.loadTests(JUnit5TestLoader.java:56)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:513)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:756)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:452)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)
Caused by: org.junit.platform.commons.JUnitException: ClassSelector [className = 'org.neo4j.gds.paths.spanningtree.SpanningTreeWriteProcTest', classLoader = jdk.internal.loader.ClassLoaders$AppClassLoader@7a4f0f29] resolution failed
    at org.junit.platform.launcher.listeners.discovery.AbortOnFailureLauncherDiscoveryListener.selectorProcessed(AbortOnFailureLauncherDiscoveryListener.java:39)
    at net.jqwik.engine.discovery.JqwikDiscoverer.lambda$discover$6(JqwikDiscoverer.java:66)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at net.jqwik.engine.discovery.JqwikDiscoverer.discover(JqwikDiscoverer.java:65)
    at net.jqwik.engine.JqwikTestEngine.discover(JqwikTestEngine.java:41)
    at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverEngineRoot(EngineDiscoveryOrchestrator.java:152)
    ... 15 more
Caused by: java.lang.NoClassDefFoundError: org/neo4j/test/TestDatabaseManagementServiceBuilder
    at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
    at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3402)
    at java.base/java.lang.Class.getDeclaredMethods(Class.java:2504)
    at org.junit.platform.commons.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:1567)
    at org.junit.platform.commons.util.ReflectionUtils.findAllMethodsInHierarchy(ReflectionUtils.java:1508)
    at org.junit.platform.commons.util.ReflectionUtils.getSuperclassMethods(ReflectionUtils.java:1714)
    at org.junit.platform.commons.util.ReflectionUtils.findAllMethodsInHierarchy(ReflectionUtils.java:1511)
    at org.junit.platform.commons.util.ReflectionUtils.getSuperclassMethods(ReflectionUtils.java:1714)
    at org.junit.platform.commons.util.ReflectionUtils.findAllMethodsInHierarchy(ReflectionUtils.java:1511)
    at org.junit.platform.commons.util.ReflectionUtils.streamMethods(ReflectionUtils.java:1493)
    at org.junit.platform.commons.util.ReflectionUtils.findMethods(ReflectionUtils.java:1478)
    at org.junit.platform.commons.support.ReflectionSupport.findMethods(ReflectionSupport.java:437)
    at net.jqwik.engine.discovery.HierarchicalJavaResolver.resolveContainedMethods(HierarchicalJavaResolver.java:166)
    at net.jqwik.engine.discovery.HierarchicalJavaResolver.resolveChildren(HierarchicalJavaResolver.java:152)
    at java.base/java.lang.Iterable.forEach(Iterable.java:75)
    at net.jqwik.engine.discovery.HierarchicalJavaResolver.lambda$resolveClass$0(HierarchicalJavaResolver.java:40)
    at net.jqwik.engine.discovery.HierarchicalJavaResolver.resolveSafely(HierarchicalJavaResolver.java:95)
    at net.jqwik.engine.discovery.HierarchicalJavaResolver.resolveClass(HierarchicalJavaResolver.java:38)
    at net.jqwik.engine.discovery.JqwikDiscoverer.lambda$discover$6(JqwikDiscoverer.java:69)
    ... 19 more
Caused by: java.lang.ClassNotFoundException: org.neo4j.test.TestDatabaseManagementServiceBuilder
    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:520)
    ... 38 more

Here's the source of my Eclipse Maven project, any help is appreciated, thanks in advance.

icejean commented 4 months ago

@vnickolov @Mats-SX

vnickolov commented 4 months ago

@icejean I've played a bit with this, updated to GDS 2.6.0 and added the classes that were causing trouble the last time around, please have a look and let us know if you have any questions Open-GDS-Extend-2.6.0.zip

icejean commented 4 months ago

@vnickolov Thanks a lot! There're many error messages saying that artifacts are missing after loading the project into my Eclipse workspace, I'll make it work on the next Monday, as I need to visit my relatives before the Spring Festival this weekend. Thanks again!

icejean commented 4 months ago

@vnickolov I can see that you've added a package org.neo4j.gds.original, and imported the two original implementations BaseTest.java and BaseProcTest.java, but the compiler prompts that original BaseTest.java has classes that cannot be resolved:

import org.neo4j.test.TestDatabaseManagementServiceBuilder;
import org.neo4j.test.extension.ExtensionCallback;
import org.neo4j.test.extension.ImpermanentDbmsExtension;

It's O.K. with Open GDS 2.5.x, may be some other artifacts should be added to the pom.xml?

icejean commented 4 months ago

@vnickolov There's a workaround at the current time, I can test my Open GDS extension Maven project in Eclipse with Neo4j Community 5.10.0 + Open GDS 2.5.5, and deploy it to Neo4j Community 5.16.0 + Open GDS 2.7.0 alpha01, which is built from the master Open GDS branch. Open-GDS-Extend-2 6 0-Eclipse-3

D:\Neo4j\neo4j-community-5.16.0\bin>neo4j console
Directories in use:
home:         D:\Neo4j\neo4j-community-5.16.0
config:       D:\Neo4j\neo4j-community-5.16.0\conf
logs:         D:\Neo4j\neo4j-community-5.16.0\logs
plugins:      D:\Neo4j\neo4j-community-5.16.0\plugins
import:       D:\Neo4j\neo4j-community-5.16.0\import
data:         D:\Neo4j\neo4j-community-5.16.0\data
certificates: D:\Neo4j\neo4j-community-5.16.0\certificates
licenses:     D:\Neo4j\neo4j-community-5.16.0\licenses
run:          D:\Neo4j\neo4j-community-5.16.0\run
Starting Neo4j.
2024-02-06 00:54:43.289+0000 INFO  Logging config in use: File 'D:\Neo4j\neo4j-community-5.16.0\conf\user-logs.xml'
2024-02-06 00:54:43.304+0000 INFO  Starting...
2024-02-06 00:54:44.197+0000 INFO  This instance is ServerId{2e528e2a} (2e528e2a-4589-4da7-a535-843c897b3762)
2024-02-06 00:54:44.784+0000 INFO  ======== Neo4j 5.16.0 ========
2024-02-06 00:54:44.859+0000 INFO  Progress tracking: enabled
2024-02-06 00:54:44.860+0000 INFO  Memory usage guard: minimum estimate
2024-02-06 00:54:44.867+0000 INFO  Register GraphDataScience...
2024-02-06 00:54:44.884+0000 INFO  GraphDataScience registered.
2024-02-06 00:54:44.885+0000 INFO  Register MetricsFacade...
2024-02-06 00:54:44.885+0000 INFO  MetricsFacade registered.
2024-02-06 00:54:44.886+0000 INFO  Register legacy Task Store/ Registry...
2024-02-06 00:54:44.886+0000 INFO  Task Store/ Registry registered.
2024-02-06 00:54:44.886+0000 INFO  Register legacy User Log Registry...
2024-02-06 00:54:44.887+0000 INFO  User Log Registry registered.
2024-02-06 00:54:44.903+0000 INFO  GDS compatibility: for Neo4j Settings 5.x -- available, for Neo4j Settings 4.4 -- not available, selected: Neo4j Settings 5.x
2024-02-06 00:54:44.903+0000 INFO  GDS compatibility: for Neo4j 5.11 -- not available, for Neo4j 5.12 -- not available, for Neo4j 5.13 -- not available, for Neo4j 5.14 -- not available, for Neo4j 5.15 -- not available, for Neo4j 5.16 -- available, for Neo4j 4.4 -- not available, selected: Neo4j 5.16
2024-02-06 00:54:50.873+0000 INFO  Bolt enabled on localhost:7687.
2024-02-06 00:54:51.413+0000 INFO  HTTP enabled on localhost:7474.
2024-02-06 00:54:51.413+0000 INFO  Remote interface available at http://localhost:7474/
2024-02-06 00:54:51.416+0000 INFO  id: 0B4D7A67BD7D4E34A65204ED7CD328AF1CAC1BE7AEFB90097350DE21862D35EC
2024-02-06 00:54:51.416+0000 INFO  name: system
2024-02-06 00:54:51.416+0000 INFO  creationDate: 2024-01-31T08:34:13.602Z
2024-02-06 00:54:51.417+0000 INFO  Started.

Open-GDS-Extend-2 6 0-Eclipse-2 But it's better to address the problem to test with Neo4j Community 5.16.0+Open GDS 2.5.6+ in Eclipse, I don't know why I get the errors saying that these 3 classes cannot be resovled, they've been there in every Open GDS version long time ago.

import org.neo4j.test.TestDatabaseManagementServiceBuilder;
import org.neo4j.test.extension.ExtensionCallback;
import org.neo4j.test.extension.ImpermanentDbmsExtension;

Open-GDS-Extend-2 6 0-Eclipse

vnickolov commented 4 months ago

@icejean the root cause for this is that the jar files published to Maven central are compiled against Neo4j 4.4.x. The Neo4j test support library in 4.4 and 5.x is binary different, which is causing the class not found errors. We have plans for moving away from Neo4j 4.4 in our next release but it is still in development, I would suggest you use the workaround for the time being and switch to the new GDS once it is released.

Could you please close this issue if the workaround is working for you?

icejean commented 4 months ago

@vnickolov Sure. :)