简体   繁体   中英

How to get mahout and neo4j in a same java project?

This is part of my pom.xml

<dependency>
    <groupId>org.apache.mahout</groupId>
    <artifactId>mahout-core</artifactId>
    <version>0.9</version>
</dependency>
<dependency>
    <groupId>org.apache.mahout</groupId>
    <artifactId>mahout-math</artifactId>
    <version>0.9</version>
</dependency>
<dependency>
     <groupId>org.neo4j</groupId>
     <artifactId>neo4j</artifactId>
     <version>2.2.1</version>
</dependency>

The ERROR is

Caused by: java.lang.ClassNotFoundException: org.apache.lucene.document.Fieldable
      at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

I found the mahout needs lucene-core 4.6.1, but the neo4j using neo4j-lucene-index 2.2.1, what can I do to solve this problem?

It's common problem. Neo4j 2.3 uses old version of the Lucene (3.6.2). In JVM you aren't able to use two different version of same library.

You have few options how to deal with it, but you should not use them in the production.

  1. Create your own Class Loader.

  2. Maven Shade plugin

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM