Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embedded Neo4j SPI Class (lucene PostingsFormat) Error

I've embedded Neo4j 3.0.1 into a Java 8 application, but I've been running into SPI issues.

Running from within IntelliJ produces the correct results as expected, but as soon as I build the artifact to a JAR, run it and attempt to write to Neo4j, I get the following exception:

Caused by: org.neo4j.kernel.impl.store.UnderlyingStorageException: 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.neo4j.kernel.impl.transaction.command.LabelUpdateWork.apply(LabelUpdateWork.java:62)
    at org.neo4j.kernel.impl.transaction.command.LabelUpdateWork.apply(LabelUpdateWork.java:33)
    at org.neo4j.concurrent.WorkSync.doSynchronizedWork(WorkSync.java:121)
    at org.neo4j.concurrent.WorkSync.apply(WorkSync.java:90)
    at org.neo4j.kernel.impl.transaction.command.IndexBatchTransactionApplier.close(IndexBatchTransactionApplier.java:105)
    at org.neo4j.kernel.impl.api.BatchTransactionApplierFacade.close(BatchTransactionApplierFacade.java:70)
    at org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageEngine.apply(RecordStorageEngine.java:336)
    at org.neo4j.kernel.impl.api.TransactionRepresentationCommitProcess.applyToStore(TransactionRepresentationCommitProcess.java:78)
    ... 25 more

There seems to be no exception starting Neo4j so I'm assuming that certain dependencies are not being resolved with the Maven build.

I have the following in my pom.xml file:

<dependency>
    <groupId>com.sparkjava</groupId>
    <artifactId>spark-core</artifactId>
    <version>2.5</version>
</dependency>

<dependency>
    <groupId>org.neo4j</groupId>
    <artifactId>neo4j</artifactId>
    <version>3.0.1</version>
    <type>pom</type>
</dependency>

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-simple</artifactId>
    <version>1.7.21</version>
</dependency>

<dependency>
    <groupId>org.apache.lucene</groupId>
    <artifactId>lucene-codecs</artifactId>
    <version>5.5.0</version>
</dependency>        

<dependency>
    <groupId>org.neo4j</groupId>
    <artifactId>neo4j-slf4j</artifactId>
    <version>3.0.0-M02</version>
</dependency>

<dependency>
    <groupId>com.google.code.gson</groupId>
    <artifactId>gson</artifactId>
    <version>2.6.2</version>
</dependency>

<dependency>
    <groupId>com.github.jknack</groupId>
    <artifactId>handlebars</artifactId>
    <version>4.0.5</version>
</dependency>

<dependency>
    <groupId>com.opencsv</groupId>
    <artifactId>opencsv</artifactId>
    <version>3.7</version>
</dependency>

<dependency>
    <groupId>commons-codec</groupId>
    <artifactId>commons-codec</artifactId>
    <version>1.10</version>
</dependency>

<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
    <version>${jackson.version}</version>
</dependency>
<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-annotations</artifactId>
    <version>${jackson.version}</version>
</dependency>
<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-core</artifactId>
    <version>${jackson.version}</version>
</dependency>

How do I resolve this issue?

UPDATE:

I've re-created this issue with a really simple blank project, source can be found here if you'd like to run it on your end: https://github.com/SeanNieuwoudt/neo4j-spi

like image 885
ghstcode Avatar asked Nov 08 '22 12:11

ghstcode


1 Answers

I took your project and executed in my eclipse. I have no issues. Here are below console logs after starting:

[Thread-0] INFO org.eclipse.jetty.util.log - Logging initialized @473ms [Thread-0] INFO spark.embeddedserver.jetty.EmbeddedJettyServer - == Spark has ignited ... [Thread-0] INFO spark.embeddedserver.jetty.EmbeddedJettyServer - >> Listening on 0.0.0.0:8080 [Thread-0] INFO org.eclipse.jetty.server.Server - jetty-9.3.6.v20151106 [Thread-0] INFO org.eclipse.jetty.server.ServerConnector - Started ServerConnector@5aa07ed2{HTTP/1.1,[http/1.1]}{0.0.0.0:8080} [Thread-0] INFO org.eclipse.jetty.server.Server - Started @772ms

While accessing - http://localhost:8080/

I got output printed as 'Hello World"

Steps i followed:

1) Downloaded your project from your github url 2) Imported as maven projects pointing to java 8 3) Maven install was successful 3) Ran main class 4) Saw the output in the browser.

Am i missing any steps to replicate actual issue?

Or is something to do with your maven. May be check your maven dependencies after running maven install to see if the expected jars are downloaded.

Good luck.

like image 191
Sudhish K Avatar answered Nov 14 '22 23:11

Sudhish K