名称为'BlockTreeOrds'的Neo4j 3.0.x PostingsFormat不存在 [英] Neo4j 3.0.x PostingsFormat with name 'BlockTreeOrds' does not exist

查看:59
本文介绍了名称为'BlockTreeOrds'的Neo4j 3.0.x PostingsFormat不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试从Neo4j 2.3升级到3.0.1.我可以将数据库作为服务启动,在那里没有问题.

I tried updating from Neo4j 2.3 to 3.0.1. I can start up the database as a service, no problem there.

但是当我尝试构建Neo4j可执行文件并运行它时,我发现了一个无法解决的错误.在Neo4j 2.x下,我可以很好地构建可执行文件.下面是我的主要方法:

But when I try to build a Neo4j executable and run it, I find a bug which I cannot resolve. Under Neo4j 2.x I can build executables fine. Below is my main method:

public class StartDB {
    public static void main(String[] args) {
        new GraphDatabaseFactory()
        .newEmbeddedDatabaseBuilder(Paths.get(args[0]).toFile())
        .loadPropertiesFromFile(args[1])
        .newGraphDatabase();
    }
}

我有一个具有1个依赖项的简单POM: <dependencies> <dependency> <groupId>org.neo4j</groupId> <artifactId>neo4j</artifactId> <version>3.0.1</version> </dependency> </dependencies>

I have a simple POM with 1 dependency: <dependencies> <dependency> <groupId>org.neo4j</groupId> <artifactId>neo4j</artifactId> <version>3.0.1</version> </dependency> </dependencies>

命令行参数分别是我的数据库和配置的路径. 下面是此图实例化错误的堆栈跟踪.

The command line arguments are the paths to my DB and config respectively. Below is the stacktrace from this graph instantiation error.

Exception in thread "main" java.lang.RuntimeException: Error starting org.neo4j.kernel.impl.factory.CommunityFacadeFactory, /home/glemmon/UPDB/data/neo4j-3.0.1/data/databases/graph.db
    at org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory.initFacade(GraphDatabaseFacadeFactory.java:144)
    at org.neo4j.kernel.impl.factory.CommunityFacadeFactory.initFacade(CommunityFacadeFactory.java:40)
    at org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory.newFacade(GraphDatabaseFacadeFactory.java:108)
    at org.neo4j.graphdb.factory.GraphDatabaseFactory.newDatabase(GraphDatabaseFactory.java:99)
    at org.neo4j.graphdb.factory.GraphDatabaseFactory.lambda$createDatabaseCreator$206(GraphDatabaseFactory.java:88)
    at org.neo4j.graphdb.factory.GraphDatabaseFactory$$Lambda$1/1313922862.newDatabase(Unknown Source)
    at org.neo4j.graphdb.factory.GraphDatabaseBuilder.newGraphDatabase(GraphDatabaseBuilder.java:183)
    at test.StartDB.main(StartDB.java:11)
Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageEngine@5483163c' failed to initialize. Please see attached cause exception.
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.init(LifeSupport.java:415)
    at org.neo4j.kernel.lifecycle.LifeSupport.init(LifeSupport.java:62)
    at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:98)
    at org.neo4j.kernel.NeoStoreDataSource.start(NeoStoreDataSource.java:502)
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:433)
    at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:107)
    at org.neo4j.kernel.impl.transaction.state.DataSourceManager.start(DataSourceManager.java:99)
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:433)
    at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:107)
    at org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory.initFacade(GraphDatabaseFacadeFactory.java:140)
    ... 7 more
Caused by: java.lang.IllegalArgumentException: An SPI class of type org.apache.lucene.codecs.PostingsFormat with name 'BlockTreeOrds' does not exist.  You need to add the corresponding JAR file supporting this SPI to your classpath.  The current classpath supports the following names: [Lucene50]
    at org.apache.lucene.util.NamedSPILoader.lookup(NamedSPILoader.java:114)
    at org.apache.lucene.codecs.PostingsFormat.forName(PostingsFormat.java:112)
    at org.apache.lucene.codecs.perfield.PerFieldPostingsFormat$FieldsReader.<init>(PerFieldPostingsFormat.java:258)
    at org.apache.lucene.codecs.perfield.PerFieldPostingsFormat.fieldsProducer(PerFieldPostingsFormat.java:341)
    at org.apache.lucene.index.SegmentCoreReaders.<init>(SegmentCoreReaders.java:104)
    at org.apache.lucene.index.SegmentReader.<init>(SegmentReader.java:65)
    at org.apache.lucene.index.ReadersAndUpdates.getReader(ReadersAndUpdates.java:145)
    at org.apache.lucene.index.ReadersAndUpdates.getReadOnlyClone(ReadersAndUpdates.java:197)
    at org.apache.lucene.index.StandardDirectoryReader.open(StandardDirectoryReader.java:99)
    at org.apache.lucene.index.IndexWriter.getReader(IndexWriter.java:435)
    at org.apache.lucene.index.DirectoryReader.open(DirectoryReader.java:100)
    at org.apache.lucene.search.SearcherManager.<init>(SearcherManager.java:106)
    at org.apache.lucene.search.SearcherManager.<init>(SearcherManager.java:76)
    at org.neo4j.kernel.api.impl.index.partition.IndexPartition.<init>(IndexPartition.java:54)
    at org.neo4j.kernel.api.impl.index.AbstractLuceneIndex.open(AbstractLuceneIndex.java:101)
    at org.neo4j.kernel.api.impl.schema.LuceneSchemaIndexProvider.indexIsOnline(LuceneSchemaIndexProvider.java:178)
    at org.neo4j.kernel.api.impl.schema.LuceneSchemaIndexProvider.getInitialState(LuceneSchemaIndexProvider.java:123)
    at org.neo4j.kernel.impl.api.index.IndexingService.init(IndexingService.java:200)
    at org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageEngine.init(RecordStorageEngine.java:403)
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.init(LifeSupport.java:405)
    ... 16 more

由于我可以使用"bin/neo4j"将数据库作为服务启动,因此我认为/neo4j-community/3.0.1/lib下的文件与Maven提供的文件之间必须存在差异.我尝试使用java -cp"/neo4j-community/3.0.1/lib/*"运行可执行文件无济于事.任何帮助将不胜感激.

Since I can start the DB as a service using "bin/neo4j", I thought there must be a discrepancy between the files under /neo4j-community/3.0.1/lib and the files Maven is providing. I've tried running my executable with java -cp "/neo4j-community/3.0.1/lib/*" to no avail. Any help would be appreciated.

推荐答案

最可能的原因是Maven没有将Lucene jar文件的META-INF/services包含到已编译的工件中:

The most likely reason is that Maven is not including the Lucene jar file's META-INF/services into the compiled artifact:

META-INF/services/org.apache.lucene.codecs.PostingsFormat

org.apache.lucene.codecs.blocktreeords.BlockTreeOrdsPostingsFormat
org.apache.lucene.codecs.bloom.BloomFilteringPostingsFormat
org.apache.lucene.codecs.memory.DirectPostingsFormat
org.apache.lucene.codecs.memory.FSTOrdPostingsFormat
org.apache.lucene.codecs.memory.FSTPostingsFormat
org.apache.lucene.codecs.memory.MemoryPostingsFormat
org.apache.lucene.codecs.simpletext.SimpleTextPostingsFormat
org.apache.lucene.codecs.autoprefix.AutoPrefixPostingsFormat

如您所见,这是定义BlockTreeOrdsPostingsFormat的地方.

As you can see, this is where the BlockTreeOrdsPostingsFormat is defined.

您可以通过创建带阴影的罐子来解决此问题ServicesResourceTransformer ,它将合并所有包含的jar文件中的所有META-INF/services.

You can work round the problem by creating a shaded jar with a ServicesResourceTransformer, which will merge all the various META-INF/services from all the included jar files together.

        <plugin>
            <artifactId>maven-shade-plugin</artifactId>
            <version>2.4.3</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                    <configuration>
                        <transformers>

                            <!-- add Main-Class to manifest file -->
                            <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                <mainClass>...</mainClass>
                            </transformer>

                            <!-- merge META-INF/services -->
                            <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
                        </transformers>
                    </configuration>
                </execution>
            </executions>
        </plugin>

这篇关于名称为'BlockTreeOrds'的Neo4j 3.0.x PostingsFormat不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆