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
597 stars 157 forks source link

Fail to run Open-GDS Junit test in Eclipse #185

Closed icejean closed 2 years ago

icejean commented 2 years ago

Hi, all, I'm planning to upgrade my GDS library 1.6.1 to higher version of OpenGDS 1.8.6 or 2.0.2, which my own algorithm is running with. My problem is , OpenGDS seems to be compiled and is running correctly in command line window, but test cases won't run in Eclipse. For example, when I try to run the Junit test case for ~/alpha/alpha-proc/src/main/java/org/neo4j/gds/spanningtree/KSpanningTreeProc.java, the test case ~/alpha/alpha-proc/src/test/java/org/neo4j/gds/KSpanningTreeProcTest.java, which I import to my Eclipse project to test, it just failed to load a test database with null pointer exception. Here's the stack trace, any idea? I think it may be some misconfigurations of pom.xml, and put it in the end. I import ~/alpha/alpha-algo/src/test/java/org/neo4j/gds/impl/spanningTree/PrimTest.java too, and it runs fine.

GDS version: 1.8.6 Neo4j version: 4.4.5 Operating system: Windows 10

java.lang.RuntimeException: Error starting Neo4j database server at D:\eclipse\workspace\OpenGDS\target\test data\org.neo4j.gds.KSpanningTreeProcTest\testb8a7cb238131887da6b7584838c57239\data\databases
    at org.neo4j.graphdb.facade.DatabaseManagementServiceFactory.startDatabaseServer(DatabaseManagementServiceFactory.java:228)
    at org.neo4j.graphdb.facade.DatabaseManagementServiceFactory.build(DatabaseManagementServiceFactory.java:181)
    at org.neo4j.test.TestDatabaseManagementServiceBuilder.newDatabaseManagementService(TestDatabaseManagementServiceBuilder.java:134)
    at org.neo4j.test.TestDatabaseManagementServiceBuilder.build(TestDatabaseManagementServiceBuilder.java:120)
    at org.neo4j.test.extension.DbmsSupportController.buildDbms(DbmsSupportController.java:163)
    at org.neo4j.test.extension.DbmsSupportController.startDbms(DbmsSupportController.java:99)
    at org.neo4j.test.extension.DbmsSupportController.startDbms(DbmsSupportController.java:87)
    at org.neo4j.test.extension.DbmsSupportExtension.beforeEach(DbmsSupportExtension.java:51)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeEachCallbacks$1(TestMethodTestDescriptor.java:159)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeMethodsOrCallbacksUntilExceptionOccurs$5(TestMethodTestDescriptor.java:195)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeMethodsOrCallbacksUntilExceptionOccurs(TestMethodTestDescriptor.java:195)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeEachCallbacks(TestMethodTestDescriptor.java:158)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:125)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:65)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:108)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:96)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:84)
    at org.eclipse.jdt.internal.junit5.runner.JUnit5TestReference.run(JUnit5TestReference.java:98)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:542)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:770)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:464)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)
    Suppressed: java.lang.NullPointerException
        at org.neo4j.test.extension.DbmsSupportController.shutdown(DbmsSupportController.java:186)
        at org.neo4j.test.extension.DbmsSupportExtension.afterEach(DbmsSupportExtension.java:60)
        at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeAfterEachCallbacks$11(TestMethodTestDescriptor.java:253)
        at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeAllAfterMethodsOrCallbacks$12(TestMethodTestDescriptor.java:269)
        at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeAllAfterMethodsOrCallbacks$13(TestMethodTestDescriptor.java:269)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
        at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeAllAfterMethodsOrCallbacks(TestMethodTestDescriptor.java:268)
        at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeAfterEachCallbacks(TestMethodTestDescriptor.java:252)
        at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:137)
        ... 45 more
Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.dbms.database.DefaultDatabaseInitializer@15cee630' was successfully initialized, but failed to start. Please see the attached cause exception "Receiver class org.neo4j.kernel.database.TestDatabaseIdRepository$RandomDatabaseIdRepository does not define or inherit an implementation of the resolved method abstract getByName(Lorg/neo4j/kernel/database/NormalizedDatabaseName;)Ljava/util/Optional; of interface org.neo4j.kernel.database.DatabaseIdRepository.".
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:463)
    at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:110)
    at org.neo4j.graphdb.facade.DatabaseManagementServiceFactory.startDatabaseServer(DatabaseManagementServiceFactory.java:219)
    ... 58 more
Caused by: java.lang.AbstractMethodError: Receiver class org.neo4j.kernel.database.TestDatabaseIdRepository$RandomDatabaseIdRepository does not define or inherit an implementation of the resolved method abstract getByName(Lorg/neo4j/kernel/database/NormalizedDatabaseName;)Ljava/util/Optional; of interface org.neo4j.kernel.database.DatabaseIdRepository.
    at org.neo4j.kernel.database.DatabaseIdRepository.getByName(DatabaseIdRepository.java:59)
    at org.neo4j.kernel.database.MapCachingDatabaseIdRepository.lambda$getByName$0(MapCachingDatabaseIdRepository.java:49)
    at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1705)
    at org.neo4j.kernel.database.MapCachingDatabaseIdRepository.getByName(MapCachingDatabaseIdRepository.java:49)
    at org.neo4j.kernel.database.DatabaseIdRepository.getByName(DatabaseIdRepository.java:59)
    at org.neo4j.dbms.database.DefaultDatabaseManager.initialiseDefaultDatabase(DefaultDatabaseManager.java:51)
    at org.neo4j.dbms.database.DefaultDatabaseInitializer.start0(DefaultDatabaseInitializer.java:39)
    at org.neo4j.kernel.lifecycle.SafeLifecycle.transition(SafeLifecycle.java:124)
    at org.neo4j.kernel.lifecycle.SafeLifecycle.start(SafeLifecycle.java:138)
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:442)
    ... 60 more
Here's my pom.xml for the maven project.
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>cn.jean.neo4j</groupId>
    <artifactId>gds-extend</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>Neo4j Spanning Arborescence</name>
    <description>Neo4j procedure for min &amp; K spanning arborescence of
        directed graph
    </description>

    <properties>
        <java.version>11</java.version>
        <maven.compiler.release>${java.version}</maven.compiler.release>

        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8
        </project.reporting.outputEncoding>
        <neo4j.version>4.4.5</neo4j.version>
        <neo4j-java-driver.version>4.4.5</neo4j-java-driver.version>
        <junit-jupiter.version>5.8.2</junit-jupiter.version>
        <maven-shade-plugin.version>3.2.4</maven-shade-plugin.version>
        <maven-compiler-plugin.version>3.10.1</maven-compiler-plugin.version>
        <assertj.version>3.22.0</assertj.version>
        <maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
    </properties>

    <dependencies>
        <!-- This gives us the Procedure API our runtime code uses. We have a `provided` 
            scope on it, because when this is deployed in a Neo4j Instance, the API will 
            be provided by Neo4j. If you add non-Neo4j dependencies to this project, 
            their scope should normally be `compile` -->
        <dependency>
            <groupId>org.neo4j</groupId>
            <artifactId>neo4j</artifactId>
            <version>${neo4j.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.neo4j.gds</groupId>
            <artifactId>core</artifactId>
            <version>1.8.6</version>
            <scope>provided</scope>
        </dependency>

        <!-- Contains the basic algorithm infrastructure -->
        <dependency>
            <groupId>org.neo4j.gds</groupId>
            <artifactId>algo-common</artifactId>
            <version>1.8.6</version>
            <scope>provided</scope>
        </dependency>

        <!-- Contains the productized algorithms -->
        <dependency>
            <groupId>org.neo4j.gds</groupId>
            <artifactId>algo</artifactId>
            <version>1.8.6</version>
            <scope>provided</scope>
        </dependency>

        <!-- Contains some alpha algorithms -->
        <dependency>
            <groupId>org.neo4j.gds</groupId>
            <artifactId>alpha-algo</artifactId>
            <version>1.8.6</version>
            <scope>provided</scope>
        </dependency>

        <!-- Contains the basic procedure infrastructure -->
        <dependency>
            <groupId>org.neo4j.gds</groupId>
            <artifactId>proc-common</artifactId>
            <version>1.8.6</version>
            <scope>provided</scope>
        </dependency>

        <!-- Contains the productized algorithm procedures -->
        <dependency>
            <groupId>org.neo4j.gds</groupId>
            <artifactId>proc</artifactId>
            <version>1.8.6</version>
            <scope>provided</scope>
        </dependency>

        <!-- Contains some alpha algorithm procedures -->
        <dependency>
            <groupId>org.neo4j.gds</groupId>
            <artifactId>alpha-proc</artifactId>
            <version>1.8.6</version>
            <scope>provided</scope>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.neo4j.gds/test-utils -->
        <dependency>
            <groupId>org.neo4j.gds</groupId>
            <artifactId>test-utils</artifactId>
            <version>1.8.6</version>
            <scope>test</scope>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.immutables/value -->
        <dependency>
            <groupId>org.immutables</groupId>
            <artifactId>value</artifactId>
            <version>2.8.8</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.realityforge.org.jetbrains.annotations</groupId>
            <artifactId>org.jetbrains.annotations</artifactId>
            <version>1.7.0</version>
            <scope>provided</scope>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven-compiler-plugin.version}</version>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven-surefire-plugin.version}</version>
            </plugin>
            <plugin>
                <!-- This generates a jar-file with our procedure code, plus any dependencies 
                    marked as `compile` scope. This should then be deployed in the `plugins` 
                    directory of each Neo4j instance in your deployment. After a restart, the 
                    procedure is available for calling. -->
                <artifactId>maven-shade-plugin</artifactId>
                <version>${maven-shade-plugin.version}</version>
                <configuration>
                    <createDependencyReducedPom>false</createDependencyReducedPom>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>
icejean commented 2 years ago

gradle :proc-test:test --tests org.neo4j.gds.impl.spanningTree.KSpanningTreeProcTest

The command above is O.K., but failed in Eclipse Junit test.

icejean commented 2 years ago

It's a configuration problem, I address the problem by matching the neo4j version according to the version mentioned in build.gradle.