Maven项目中的Neo4j和Elasticsearch问题



在Maven项目中,是否可以在同一类路径上使用Neo4j和Elasticsearch(两者都使用Lucene internally)?

    <dependency>
        <groupId>org.elasticsearch</groupId>
        <artifactId>elasticsearch</artifactId>
        <version>1.4.4</version>
    </dependency>
    <dependency>
        <groupId>org.neo4j</groupId>
        <artifactId>neo4j</artifactId>
        <version>2.1.7</version>
    </dependency>

我有以下例外:

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.neo4j.graphdb.GraphDatabaseService]: Circular reference involving containing bean 'neo4jTestConfig' - consider declaring the factory method as static for independence from its containing instance. Factory method 'graphDatabaseService' threw exception; nested exception is java.lang.RuntimeException: Error starting org.neo4j.kernel.EmbeddedGraphDatabase, domaintargettest-neo4j-db
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189) ~[spring-beans-4.1.5.RELEASE.jar:4.1.5.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588) ~[spring-beans-4.1.5.RELEASE.jar:4.1.5.RELEASE]
    ... 54 common frames omitted
Caused by: java.lang.RuntimeException: Error starting org.neo4j.kernel.EmbeddedGraphDatabase, domaintargettest-neo4j-db
    at org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:366) ~[neo4j-kernel-2.1.7.jar:2.1.7]
    at org.neo4j.kernel.EmbeddedGraphDatabase.<init>(EmbeddedGraphDatabase.java:59) ~[neo4j-kernel-2.1.7.jar:2.1.7]
    at org.neo4j.graphdb.factory.GraphDatabaseFactory$1.newDatabase(GraphDatabaseFactory.java:91) ~[neo4j-kernel-2.1.7.jar:2.1.7]
    at org.neo4j.graphdb.factory.GraphDatabaseBuilder.newGraphDatabase(GraphDatabaseBuilder.java:181) ~[neo4j-kernel-2.1.7.jar:2.1.7]
    at org.neo4j.graphdb.factory.GraphDatabaseFactory.newEmbeddedDatabase(GraphDatabaseFactory.java:71) ~[neo4j-kernel-2.1.7.jar:2.1.7]
    at com.example.domain.configuration.Neo4jTestConfig.graphDatabaseService(Neo4jTestConfig.java:36) ~[test-classes/:na]
    at com.example.domain.configuration.Neo4jTestConfig$$EnhancerBySpringCGLIB$$333d76d.CGLIB$graphDatabaseService$0(<generated>) ~[spring-core-4.1.5.RELEASE.jar:na]
    at com.example.domain.configuration.Neo4jTestConfig$$EnhancerBySpringCGLIB$$333d76d$$FastClassBySpringCGLIB$$aa2eee7d.invoke(<generated>) ~[spring-core-4.1.5.RELEASE.jar:na]
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[spring-core-4.1.5.RELEASE.jar:4.1.5.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:309) ~[spring-context-4.1.5.RELEASE.jar:4.1.5.RELEASE]
    at com.example.domain.configuration.Neo4jTestConfig$$EnhancerBySpringCGLIB$$333d76d.graphDatabaseService(<generated>) ~[spring-core-4.1.5.RELEASE.jar:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_25]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_25]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_25]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_25]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162) ~[spring-beans-4.1.5.RELEASE.jar:4.1.5.RELEASE]
    ... 55 common frames omitted
Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.kernel.extension.KernelExtensions@222eb8aa' failed to initialize. Please see attached cause exception.
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.init(LifeSupport.java:489) ~[neo4j-kernel-2.1.7.jar:2.1.7]
    at org.neo4j.kernel.lifecycle.LifeSupport.init(LifeSupport.java:72) ~[neo4j-kernel-2.1.7.jar:2.1.7]
    at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:106) ~[neo4j-kernel-2.1.7.jar:2.1.7]
    at org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:343) ~[neo4j-kernel-2.1.7.jar:2.1.7]
    ... 70 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/apache/lucene/document/Fieldable
    at org.neo4j.kernel.api.impl.index.NodeRangeDocumentLabelScanStorageStrategy.<init>(NodeRangeDocumentLabelScanStorageStrategy.java:70) ~[neo4j-lucene-index-2.1.7.jar:2.1.7]
    at org.neo4j.kernel.api.impl.index.LuceneLabelScanStoreExtension.newKernelExtension(LuceneLabelScanStoreExtension.java:73) ~[neo4j-lucene-index-2.1.7.jar:2.1.7]
    at org.neo4j.kernel.api.impl.index.LuceneLabelScanStoreExtension.newKernelExtension(LuceneLabelScanStoreExtension.java:39) ~[neo4j-lucene-index-2.1.7.jar:2.1.7]
    at org.neo4j.kernel.extension.KernelExtensions.init(KernelExtensions.java:104) ~[neo4j-kernel-2.1.7.jar:2.1.7]
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.init(LifeSupport.java:483) ~[neo4j-kernel-2.1.7.jar:2.1.7]
    ... 73 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.apache.lucene.document.Fieldable
    at java.net.URLClassLoader$1.run(Unknown Source) ~[na:1.8.0_25]
    at java.net.URLClassLoader$1.run(Unknown Source) ~[na:1.8.0_25]
    at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_25]
    at java.net.URLClassLoader.findClass(Unknown Source) ~[na:1.8.0_25]
    at java.lang.ClassLoader.loadClass(Unknown Source) ~[na:1.8.0_25]
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) ~[na:1.8.0_25]
    at java.lang.ClassLoader.loadClass(Unknown Source) ~[na:1.8.0_25]
    ... 78 common frames omitted

当我试图排除neo4j lucene指数

    <dependency>
        <groupId>org.neo4j</groupId>
        <artifactId>neo4j</artifactId>
        <version>2.1.7</version>
        <exclusions>
            <exclusion>
                <groupId>org.neo4j</groupId>
                <artifactId>neo4j-lucene-index</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

我得到一个例外:

Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.kernel.impl.nioneo.xa.NeoStoreXaDataSource@4ae33a11' was successfully initialized, but failed to start. Please see attached cause exception.
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:513) ~[neo4j-kernel-2.1.7.jar:2.1.7]
    at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:115) ~[neo4j-kernel-2.1.7.jar:2.1.7]
    at org.neo4j.kernel.impl.transaction.XaDataSourceManager.start(XaDataSourceManager.java:164) ~[neo4j-kernel-2.1.7.jar:2.1.7]
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:507) ~[neo4j-kernel-2.1.7.jar:2.1.7]
    ... 72 common frames omitted
Caused by: java.lang.IllegalArgumentException: No schema index provider org.neo4j.kernel.api.index.SchemaIndexProvider found. Kernel extensions available on classpath: 

我不想使用Neo4j遗留索引,并希望在我的应用程序中实现基于Elasticsearch引擎的模糊搜索。是否可以在同一类路径上同时使用这两个系统?

由于lucene没有将其包名称从3.x更改为4.x,两个版本的类将发生冲突。

如果你有冒险精神,你可以尝试为Neo4j构建这个Lucene 4.x分支。

通过将外部ES与Neo4j集成,您可能会过得更好。

相关内容

  • 没有找到相关文章

最新更新