我正在尝试编写一个neo4j过程,它将一些数据写入cassandra集群。我还需要在部署中使用graphaware框架,它是我需要的graphaware模块所必需的。
我正在用docker compose文件运行neo4j:3.5.4。我在neo4j的plugins文件夹中有jar graphaware-server-community-all-3.5.4.53.jar。
我编写了一个程序,负责将neo4j中的数据写入cassandra,并对其进行了测试,无需加载graphaware框架。很好用。
但是当我的过程和框架都在plugins目录下时,我不能启动neo4j。
出于调试的目的,这里我不使用真正的过程,而是使用一个简单的计数器过程。pom中的依赖com.datastax.cassandra足以触发问题。
pom.xml文件
<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
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.neo4j.example</groupId>
<artifactId>procedure-template</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Neo4j Procedure Template</name>
<description>A template project for building a Neo4j Procedure</description>
<properties>
<neo4j.version>3.5.4</neo4j.version>
</properties>
<dependencies>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j</artifactId>
<version>${neo4j.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.neo4j.test</groupId>
<artifactId>neo4j-harness</artifactId>
<version>${neo4j.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.neo4j.driver</groupId>
<artifactId>neo4j-java-driver</artifactId>
<version>1.7.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
<version>3.1.4</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
程序
@Procedure(value="test.ab.count")
public Stream<CountResult> count(@Name("label") String label){
Long count = (long) 0;
ResourceIterator<Node> nodes = db.findNodes(Label.label(label));
while(nodes.hasNext()){
nodes.next();
count += 1;
}
nodes.close();
return Stream.of(new CountResult(count));
}
使用countresult对象:
public class CountResult{
public final static StringResult EMPTY = new StringResult(null);
public final Long value;
public CountResult(Long value){
this.value=value;
}
}
我把这个包起来
mvn clean package -DskipTests
使用过程和graphaware框架运行compose时得到的结果是:
Starting docker-n-test_neo4j_1_ac35c08081cc ... done
Attaching to docker-n-test_neo4j_1_ac35c08081cc
neo4j_1_ac35c08081cc | command failed: the provided initial password was not set because existing Neo4j users were detected at `/var/lib/neo4j/data/dbms/auth`. Please remove the existing `auth` and `roles` files if you want to reset your database to only have a default user with the provided password.
neo4j_1_ac35c08081cc | Active database: graph.db
neo4j_1_ac35c08081cc | Directories in use:
neo4j_1_ac35c08081cc | home: /var/lib/neo4j
neo4j_1_ac35c08081cc | config: /var/lib/neo4j/conf
neo4j_1_ac35c08081cc | logs: /logs
neo4j_1_ac35c08081cc | plugins: /plugins
neo4j_1_ac35c08081cc | import: NOT SET
neo4j_1_ac35c08081cc | data: /var/lib/neo4j/data
neo4j_1_ac35c08081cc | certificates: /var/lib/neo4j/certificates
neo4j_1_ac35c08081cc | run: /var/lib/neo4j/run
neo4j_1_ac35c08081cc | Starting Neo4j.
neo4j_1_ac35c08081cc | 2019-07-01 11:20:22.257+0000 WARN Unknown config option: causal_clustering.discovery_listen_address
neo4j_1_ac35c08081cc | 2019-07-01 11:20:22.259+0000 WARN Unknown config option: metrics.prometheus.endpoint
neo4j_1_ac35c08081cc | 2019-07-01 11:20:22.259+0000 WARN Unknown config option: causal_clustering.raft_advertised_address
neo4j_1_ac35c08081cc | 2019-07-01 11:20:22.260+0000 WARN Unknown config option: causal_clustering.raft_listen_address
neo4j_1_ac35c08081cc | 2019-07-01 11:20:22.260+0000 WARN Unknown config option: ha.host.coordination
neo4j_1_ac35c08081cc | 2019-07-01 11:20:22.260+0000 WARN Unknown config option: metrics.prometheus.enabled
neo4j_1_ac35c08081cc | 2019-07-01 11:20:22.260+0000 WARN Unknown config option: causal_clustering.transaction_advertised_address
neo4j_1_ac35c08081cc | 2019-07-01 11:20:22.260+0000 WARN Unknown config option: causal_clustering.discovery_advertised_address
neo4j_1_ac35c08081cc | 2019-07-01 11:20:22.260+0000 WARN Unknown config option: ha.host.data
neo4j_1_ac35c08081cc | 2019-07-01 11:20:22.260+0000 WARN Unknown config option: causal_clustering.transaction_listen_address
neo4j_1_ac35c08081cc | 2019-07-01 11:20:22.269+0000 INFO ======== Neo4j 3.5.4 ========
neo4j_1_ac35c08081cc | 2019-07-01 11:20:22.273+0000 INFO Starting...
neo4j_1_ac35c08081cc | 2019-07-01 11:20:24.818+0000 INFO GraphAware Runtime enabled, bootstrapping...
neo4j_1_ac35c08081cc | 2019-07-01 11:20:24.834+0000 INFO GraphAware Runtime bootstrapped, starting the Runtime...
neo4j_1_ac35c08081cc | 2019-07-01 11:20:24.915+0000 INFO Starting GraphAware...
neo4j_1_ac35c08081cc | 2019-07-01 11:20:24.916+0000 INFO Loading module metadata...
neo4j_1_ac35c08081cc | 2019-07-01 11:20:24.953+0000 INFO Module metadata loaded.
neo4j_1_ac35c08081cc | 2019-07-01 11:20:24.953+0000 INFO Starting transaction-driven modules...
neo4j_1_ac35c08081cc | 2019-07-01 11:20:24.954+0000 INFO Transaction-driven modules started.
neo4j_1_ac35c08081cc | 2019-07-01 11:20:24.954+0000 INFO There are no timer-driven runtime modules. Not scheduling any tasks.
neo4j_1_ac35c08081cc | 2019-07-01 11:20:24.954+0000 INFO GraphAware started.
neo4j_1_ac35c08081cc | 2019-07-01 11:20:24.954+0000 INFO GraphAware Runtime automatically started.
neo4j_1_ac35c08081cc | 2019-07-01 11:20:29.590+0000 INFO Shutting down GraphAware Runtime...
neo4j_1_ac35c08081cc | 2019-07-01 11:20:29.590+0000 INFO Terminating task scheduler...
neo4j_1_ac35c08081cc | 2019-07-01 11:20:29.591+0000 INFO Task scheduler terminated successfully.
neo4j_1_ac35c08081cc | 2019-07-01 11:20:29.591+0000 INFO GraphAware Runtime shut down.
neo4j_1_ac35c08081cc | 2019-07-01 11:20:29.629+0000 ERROR Failed to start Neo4j: Starting Neo4j failed: Component 'org.neo4j.server.database.LifecycleManagingDatabase@3566d527' was successfully initialized, but failed to start. Please see the attached cause exception "Implementing class". Starting Neo4j failed: Component 'org.neo4j.server.database.LifecycleManagingDatabase@3566d527' was successfully initialized, but failed to start. Please see the attached cause exception "Implementing class".
neo4j_1_ac35c08081cc | org.neo4j.server.ServerStartupException: Starting Neo4j failed: Component 'org.neo4j.server.database.LifecycleManagingDatabase@3566d527' was successfully initialized, but failed to start. Please see the attached cause exception "Implementing class".
neo4j_1_ac35c08081cc | at org.neo4j.server.exception.ServerStartupErrors.translateToServerStartupError(ServerStartupErrors.java:45)
neo4j_1_ac35c08081cc | at org.neo4j.server.AbstractNeoServer.start(AbstractNeoServer.java:187)
neo4j_1_ac35c08081cc | at org.neo4j.server.ServerBootstrapper.start(ServerBootstrapper.java:123)
neo4j_1_ac35c08081cc | at org.neo4j.server.ServerBootstrapper.start(ServerBootstrapper.java:90)
neo4j_1_ac35c08081cc | at org.neo4j.server.CommunityEntryPoint.main(CommunityEntryPoint.java:32)
neo4j_1_ac35c08081cc | Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.server.database.LifecycleManagingDatabase@3566d527' was successfully initialized, but failed to start. Please see the attached cause exception "Implementing class".
neo4j_1_ac35c08081cc | at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:473)
neo4j_1_ac35c08081cc | at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:111)
neo4j_1_ac35c08081cc | at org.neo4j.server.AbstractNeoServer.start(AbstractNeoServer.java:180)
neo4j_1_ac35c08081cc | ... 3 more
neo4j_1_ac35c08081cc | Caused by: java.lang.RuntimeException: Error starting org.neo4j.graphdb.facade.GraphDatabaseFacadeFactory, /data/databases
neo4j_1_ac35c08081cc | at org.neo4j.graphdb.facade.GraphDatabaseFacadeFactory.initFacade(GraphDatabaseFacadeFactory.java:229)
neo4j_1_ac35c08081cc | at org.neo4j.graphdb.facade.GraphDatabaseFacadeFactory.newFacade(GraphDatabaseFacadeFactory.java:146)
neo4j_1_ac35c08081cc | at org.neo4j.server.database.CommunityGraphFactory.newGraphDatabase(CommunityGraphFactory.java:41)
neo4j_1_ac35c08081cc | at org.neo4j.server.database.LifecycleManagingDatabase.start(LifecycleManagingDatabase.java:90)
neo4j_1_ac35c08081cc | at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:452)
neo4j_1_ac35c08081cc | ... 5 more
neo4j_1_ac35c08081cc | Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.kernel.impl.proc.Procedures@4c1dc246' was successfully initialized, but failed to start. Please see the attached cause exception "Implementing class".
neo4j_1_ac35c08081cc | at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:473)
neo4j_1_ac35c08081cc | at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:111)
neo4j_1_ac35c08081cc | at org.neo4j.graphdb.facade.GraphDatabaseFacadeFactory.initFacade(GraphDatabaseFacadeFactory.java:224)
neo4j_1_ac35c08081cc | ... 9 more
neo4j_1_ac35c08081cc | Caused by: java.lang.IncompatibleClassChangeError: Implementing class
neo4j_1_ac35c08081cc | at java.lang.ClassLoader.defineClass1(Native Method)
neo4j_1_ac35c08081cc | at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
neo4j_1_ac35c08081cc | at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
neo4j_1_ac35c08081cc | at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
neo4j_1_ac35c08081cc | at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
neo4j_1_ac35c08081cc | at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
neo4j_1_ac35c08081cc | at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
neo4j_1_ac35c08081cc | at java.security.AccessController.doPrivileged(Native Method)
neo4j_1_ac35c08081cc | at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
neo4j_1_ac35c08081cc | at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
neo4j_1_ac35c08081cc | at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
neo4j_1_ac35c08081cc | at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
neo4j_1_ac35c08081cc | at java.lang.Class.getDeclaredMethods0(Native Method)
neo4j_1_ac35c08081cc | at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
neo4j_1_ac35c08081cc | at java.lang.Class.getDeclaredMethods(Class.java:1975)
neo4j_1_ac35c08081cc | at org.neo4j.kernel.impl.proc.ProcedureJarLoader$1.fetchNextOrNull(ProcedureJarLoader.java:166)
neo4j_1_ac35c08081cc | at org.neo4j.kernel.impl.proc.ProcedureJarLoader$1.fetchNextOrNull(ProcedureJarLoader.java:138)
neo4j_1_ac35c08081cc | at org.neo4j.collection.PrefetchingRawIterator.peek(PrefetchingRawIterator.java:50)
neo4j_1_ac35c08081cc | at org.neo4j.collection.PrefetchingRawIterator.hasNext(PrefetchingRawIterator.java:36)
neo4j_1_ac35c08081cc | at org.neo4j.kernel.impl.proc.ProcedureJarLoader.loadProcedures(ProcedureJarLoader.java:111)
neo4j_1_ac35c08081cc | at org.neo4j.kernel.impl.proc.ProcedureJarLoader.loadProceduresFromDir(ProcedureJarLoader.java:85)
neo4j_1_ac35c08081cc | at org.neo4j.kernel.impl.proc.Procedures.start(Procedures.java:323)
neo4j_1_ac35c08081cc | at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:452)
neo4j_1_ac35c08081cc | ... 11 more
neo4j_1_ac35c08081cc | 2019-07-01 11:20:29.632+0000 INFO Neo4j Server shutdown initiated by request
docker-n-test_neo4j_1_ac35c08081cc exited with code 1
我想不出一个解决办法来进行这项工作,我也不确定是什么问题。
暂无答案!
目前还没有任何答案,快来回答吧!