Search code examples
eclipsemavenneo4jm2eclipse

"NoClassDefFoundError" in maven


I am attempting to create a server plugin by following this tutorial http://docs.neo4j.org/chunked/milestone/server-plugins.html

i've created a maven project (following this tutorial http://blog.neo4j.org/2012/03/how-to-set-up-maven-project-with-neo4j.html) in eclipse and added the necessary dependencies from the maven repository, which i saw actually in the pom.xml and in the list of maven dependencies, and then i created my jar using the goal "clean install" and added it to neo4j plugins.

The latter plugin has been correctly added and i could check that thanks to :

curl -v http://localhost:7474/db/data/ 

but what is strange, is that i am getting the error below when i try to run it from the shell :

I am sure that the dependencies were really added when the jar was created ( i checked this using : mvn dependency:tree -Dverbose and the package "org.lucene.lucene-spellchecker" containing this class was added as well)

Any help would be really appreciated.

Thank you


dependency tree:

[INFO] org.neo4j.server.plugin.custom:neo4j-didYouMean-plugin:jar:1.9.M05
[INFO] +- junit:junit:jar:3.8.1:test
[INFO] +- org.neo4j:neo4j:jar:1.9.M05:compile
[INFO] |  +- org.neo4j:neo4j-kernel:jar:1.9.M05:compile
[INFO] |  |  \- org.apache.geronimo.specs:geronimo-jta_1.1_spec:jar:1.1.1:compile
[INFO] |  +- org.neo4j:neo4j-lucene-index:jar:1.9.M05:compile
[INFO] |  |  +- (org.neo4j:neo4j-kernel:jar:1.9.M05:compile - omitted for duplicate)
[INFO] |  |  \- (org.apache.lucene:lucene-core:jar:3.5.0:compile - omitted for     duplicate)
[INFO] |  +- org.neo4j:neo4j-graph-algo:jar:1.9.M05:compile
[INFO] |  |  \- (org.neo4j:neo4j-kernel:jar:1.9.M05:compile - omitted for duplicate)
[INFO] |  +- org.neo4j:neo4j-udc:jar:1.9.M05:compile
[INFO] |  |  \- (org.neo4j:neo4j-kernel:jar:1.9.M05:compile - omitted for duplicate)
[INFO] |  +- org.neo4j:neo4j-graph-matching:jar:1.9.M05:compile
[INFO] |  |  \- (org.neo4j:neo4j-kernel:jar:1.9.M05:compile - omitted for duplicate)
[INFO] |  +- org.neo4j:neo4j-cypher:jar:1.9.M05:compile
[INFO] |  |  +- org.scala-lang:scala-library:jar:2.10.0:compile  
[INFO] |  |  +- (org.neo4j:neo4j-lucene-index:jar:1.9.M05:compile - omitted for duplicate)
[INFO] |  |  +- (org.neo4j:neo4j-graph-matching:jar:1.9.M05:compile - omitted for  duplicate)
[INFO] |  |  +- (org.neo4j:neo4j-kernel:jar:1.9.M05:compile - omitted for duplicate)
[INFO] |  |  +- (org.neo4j:neo4j-graph-algo:jar:1.9.M05:compile - omitted for duplicate)
[INFO] |  |  \- com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap- lru:jar:1.3.1:compile
[INFO] |  \- org.neo4j:neo4j-jmx:jar:1.9.M05:compile
[INFO] +- org.neo4j:server-api:jar:1.9.M05:compile
[INFO] |  +- (org.neo4j:neo4j-kernel:jar:1.9.M05:compile - omitted for duplicate)
[INFO] |  +- org.neo4j.3rdparty.javax.ws.rs:jsr311-api:jar:1.1.2.r612:compile
[INFO] |  +- commons-configuration:commons-configuration:jar:1.6:compile
[INFO] |  |  +- commons-collections:commons-collections:jar:3.2.1:compile
[INFO] |  |  +- commons-lang:commons-lang:jar:2.4:compile 
[INFO] |  |  +- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] |  |  \- commons-beanutils:commons-beanutils-core:jar:1.8.0:compile
[INFO] |  |     \- (commons-logging:commons-logging:jar:1.1.1:compile - omitted for duplicate)
[INFO] |  \- commons-digester:commons-digester:jar:1.8.1:compile
[INFO] |     +- commons-beanutils:commons-beanutils:jar:1.8.0:compile
[INFO] |     |  \- (commons-logging:commons-logging:jar:1.1.1:compile - omitted for duplicate)
[INFO] |     \- (commons-logging:commons-logging:jar:1.1.1:compile - omitted for duplicate)
[INFO] \- org.apache.lucene:lucene-spellchecker:jar:3.5.0:compile
[INFO]    +- org.apache.lucene:lucene-core:jar:3.5.0:compile  
[INFO]    \- org.apache.lucene:lucene-analyzers:jar:3.5.0:compile
[INFO]       \- (org.apache.lucene:lucene-core:jar:3.5.0:compile - omitted for duplicate)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS

error:

 curl -X POST http://localhost:7474/db/data/ext/DidYouMeanPlugin/graphdb/didYouMean -H "Content-Type:application/json" -d '{"query":"san francisco", "searchType":"airports" , "max":10}'

{
  "message" : "org/apache/lucene/search/spell/LevensteinDistance",
  "exception" : "NoClassDefFoundError",
  "fullname" : "java.lang.NoClassDefFoundError",
  "stacktrace" : [    
           "org.neo4j.server.plugin.didYouMean.DidYouMeanPlugin.didYouMean(DidYouMeanPlugin.java:39)",   "java.lang.reflect.Method.invoke(Method.java:601)", "org.neo4j.server.plugins.PluginMethod.invoke(PluginMethod.java:57)", "org.neo4j.server.plugins.PluginManager.invoke(PluginManager.java:168)", "org.neo4j.server.rest.web.ExtensionService.invokeGraphDatabaseExtension(ExtensionService.java:300)", "org.neo4j.server.rest.web.ExtensionService.invokeGraphDatabaseExtension(ExtensionService.java:122)", "java.lang.reflect.Method.invoke(Method.java:601)" ]

Solution

  • Ccan you check the jar file with jar tf file if the lucene class is really in there?

    Did you create it with mvn assembly single?

    What you can also do is to use mvn dependency:copy-dependencies and copy those additional jar files into the plugins folder of your sever installation.