scala - java.lang.NoClassDefFoundError: org/apache/lucene/codecs/simpletext/SimpleTextCodec -
i want perform unit testing in elasticsearch using java-test-framework
using elasticsearch-1.6.0
, referring these link https://www.elastic.co/guide/en/elasticsearch/reference/1.6/using-elasticsearch-test-classes.html https://github.com/elastic/elasticsearch/blob/master/core/src/test/java/org/elasticsearch/action/search/searchrequestbuildertests.java
here code
class campaignestest extends estestcase { def getclient():mocktransportclient={ val settings = settings.builder() .put(environment.path_home_setting.getkey(), files.createtempdir().tostring()) .build(); val client = new mocktransportclient(settings); client } } class campaigntestsearch extends playspec{ val client=new campaignestest val response = client.preparesearch("dbtest") .settypes(campaign_collection_name) .setsearchtype(searchtype.dfs_query_then_fetch) .addfields("uuid","campaignname","artworkid","activationdate","_source") .setquery(query) .execute() .actionget() }
i getting exception
exception encountered when attempting run suite class name: org.scalatest.deferredabortedsuite *** aborted *** [info] java.lang.noclassdeffounderror: org/apache/lucene/codecs/simpletext/simpletextcodec [info] @ org.apache.lucene.util.lucenetestcase.<clinit>(lucenetestcase.java:616) [info] @ testcontrollers.campaign.campaigntestsearch.<init>(campaigntestsearch.scala:40) [info] @ sun.reflect.nativeconstructoraccessorimpl.newinstance0(native method) [info] @ sun.reflect.nativeconstructoraccessorimpl.newinstance(nativeconstructoraccessorimpl.java:62) [info] @ sun.reflect.delegatingconstructoraccessorimpl.newinstance(delegatingconstructoraccessorimpl.java:45) [info] @ java.lang.reflect.constructor.newinstance(constructor.java:423) [info] @ java.lang.class.newinstance(class.java:442) [info] @ org.scalatest.tools.framework$scalatesttask.execute(framework.scala:468) [info] @ sbt.forkmain$run$2.call(forkmain.java:296) [info] @ sbt.forkmain$run$2.call(forkmain.java:286) [info] ... [info] cause: java.lang.classnotfoundexception: org.apache.lucene.codecs.simpletext.simpletextcodec [info] @ java.net.urlclassloader.findclass(urlclassloader.java:381) [info] @ java.lang.classloader.loadclass(classloader.java:424) [info] @ sun.misc.launcher$appclassloader.loadclass(launcher.java:331) [info] @ java.lang.classloader.loadclass(classloader.java:357) [info] @ org.apache.lucene.util.lucenetestcase.<clinit>(lucenetestcase.java:616) [info] @ testcontrollers.campaign.campaigntestsearch.<init>(campaigntestsearch.scala:40) [info] @ sun.reflect.nativeconstructoraccessorimpl.newinstance0(native method) [info] @ sun.reflect.nativeconstructoraccessorimpl.newinstance(nativeconstructoraccessorimpl.java:62) [info] @ sun.reflect.delegatingconstructoraccessorimpl.newinstance(delegatingconstructoraccessorimpl.java:45) [info] @ java.lang.reflect.constructor.newinstance(constructor.java:423) [info] ...
getting exception on line
val client=new campaignestest
in class campaigntestsearch
here dependencies in build.sbt
file
"org.elasticsearch" % "elasticsearch" % "1.6.0", "org.elasticsearch.test" % "framework" % "5.0.0" % "test", "org.apache.lucene" % "lucene-test-framework" % "4.10.4" % "test", "com.carrotsearch.randomizedtesting" % "randomizedtesting-runner" % "1.6.0" % "test", "org.a"org.apache.lucene" % "lucene-expressions" % "4.10.4", pache.lucene" % "lucene-backward-codecs" % "5.4.0",
i suspect cause of exception maybe due versions of dependencies can please correct library dependency version make work or tehre else missing
two problems:
simpletextcodec
in codecs, not backwards-codecs.you using jar lucene 5.4.0. never mix-and-match lucene versions. elasticsearch 1.6.0 designed work lucene 4.10.4. mixing in jar lucene 5.4.0 can cause problems you.
Comments
Post a Comment