Neo4j社区2.3.3 Linux(Ubuntu 14.04)
尝试运行使用Kafka主题的Java应用程序,在查询Neo4j时处理其消息,并将它们写入另一个Kafka主题。
hduser@ubuntu:~$ java -jar gradle1-0.1.0.jar localhost:9092 musicgrp raw-events enriched-events bad-events /home/ubuntu/GeoLiteCity.dat
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" java.lang.RuntimeException: Error starting org.neo4j.kernel.impl.factory.CommunityFacadeFactory, /home/hduser/neo4jdb2/data/graph.db
at org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory.newFacade(GraphDatabaseFacadeFactory.java:143)
at org.neo4j.kernel.impl.factory.CommunityFacadeFactory.newFacade(CommunityFacadeFactory.java:43)
at org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory.newFacade(GraphDatabaseFacadeFactory.java:108)
at org.neo4j.graphdb.factory.GraphDatabaseFactory.newDatabase(GraphDatabaseFactory.java:129)
at org.neo4j.graphdb.factory.GraphDatabaseFactory$1.newDatabase(GraphDatabaseFactory.java:117)
at org.neo4j.graphdb.factory.GraphDatabaseBuilder.newGraphDatabase(GraphDatabaseBuilder.java:185)
at music.StreamApp.main(StreamApp.java:40)
Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.kernel.NeoStoreDataSource@1d606256' was successfully initialized, but failed to start. Please see attached cause exception.
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:462)
at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:111)
at org.neo4j.kernel.impl.transaction.state.DataSourceManager.start(DataSourceManager.java:112)
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:452)
at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:111)
at org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory.newFacade(GraphDatabaseFacadeFactory.java:139)
... 6 more
Caused by: org.neo4j.kernel.impl.util.UnsatisfiedDependencyException: No dependency satisfies type class org.neo4j.kernel.api.index.SchemaIndexProvider
at org.neo4j.kernel.impl.util.Dependencies.resolveDependency(Dependencies.java:78)
at org.neo4j.kernel.impl.util.Dependencies.resolveDependency(Dependencies.java:74)
at org.neo4j.kernel.NeoStoreDataSource.start(NeoStoreDataSource.java:507)
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:452)
... 11 more
这是我的 gradle.build ,我读了一些关于将Neo4j罐子从捆绑中取出的帖子......用--classpath
指向它的罐子......我'对Gradle来说,这是相关的吗?
apply plugin: 'java'
apply plugin: 'application'
sourceCompatibility = '1.8'
mainClassName = 'music.StreamApp'
repositories {
mavenCentral()
}
version = '0.1.0'
dependencies {
compile 'org.apache.kafka:kafka-clients:0.9.0.0'
compile 'com.maxmind.geoip:geoip-api:1.2.14'
compile 'com.fasterxml.jackson.core:jackson-databind:2.6.3'
compile 'org.slf4j:slf4j-api:1.7.5'
compile 'org.neo4j:neo4j:2.3.3'
}
jar { // c
manifest {
attributes 'Main-Class': mainClassName
}
from {
configurations.compile.collect {
it.isDirectory() ? it : zipTree(it)
}
} {
exclude "META-INF/*.SF"
exclude "META-INF/*.DSA"
exclude "META-INF/*.RSA"
}
}
答案 0 :(得分:2)
我怀疑你的jar中没有next
个文件。在内部,Neo4j使用JVM的ServiceLoader来加载其组件。
我认为解决这个问题的正确方法不是通过更改Gradle的默认jar任务,而是使用正确处理Null
文件的插件。我已经使用shadow plugin获得了一些很好的体验。
答案 1 :(得分:2)
就我而言(Neo4j Shell Tools 3.0.3,Gradle 2.13),添加mergeServiceFiles()
是解决此问题的关键:
plugins { id "com.github.johnrengelman.shadow" version "1.2.3" }
shadowJar {
classifier = 'fat'
mergeServiceFiles()
manifest { attributes 'Main-Class': '...' }
}
无需指定确切的文件(META-INF/...
)。