java.lang.NoClassDefFoundError的:组织/阿帕奇/ Lucene的/ codeCS / codeC [英] java.lang.NoClassDefFoundError: org/apache/lucene/codecs/Codec

查看:278
本文介绍了java.lang.NoClassDefFoundError的:组织/阿帕奇/ Lucene的/ codeCS / codeC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目需要的Lucene( 4.3.0 ),并添加以下dependenies: Lucene的核心,lucene的-分析仪常见,lucene的-查询的Lucene QueryParser的。

I have a project needing Lucene(4.3.0) and add the following dependenies: lucene-core,lucene-analyzers-common,lucene-queries,lucene-queryparser.

和,之后添加lucene- codeCS的依赖,也得到了同样的错误。

And,after add lucene-codecs dependency,also get the same error.

不过,Lucene的核心的jar包含在 codeC

but, the lucene-core jar contains the Codec class

-----开始异常-----

----- begin exception -----

I/TestRunner(2443): java.lang.NoClassDefFoundError: org/apache/lucene/codecs/Codec
I/TestRunner(2443):     at org.apache.lucene.index.LiveIndexWriterConfig.<init>(LiveIndexWriterConfig.java:118)
I/TestRunner(2443):     at org.apache.lucene.index.IndexWriterConfig.<init>(IndexWriterConfig.java:144)
I/TestRunner(2443):     at com.my.search.SearchIndexManager.newWriter(SearchIndexManager.java:301)
I/TestRunner(2443):     at com.my.search.SearchIndexManager.addIndexState(SearchIndexManager.java:95)
I/TestRunner(2443):     at com.my.SearchOperation.addIndexer(SearchOperation.java:68)
I/TestRunner(2443):     at com.my.test.SearchOperationTest.testSearchWithFilter(SearchOperationTest.java:208)
I/TestRunner(2443):     at java.lang.reflect.Method.invokeNative(Native Method)
I/TestRunner(2443):     at java.lang.reflect.Method.invoke(Method.java:511)
I/TestRunner(2443):     at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)
I/TestRunner(2443):     at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)
I/TestRunner(2443):     at junit.framework.TestCase.runBare(TestCase.java:134)
I/TestRunner(2443):     at junit.framework.TestResult$1.protect(TestResult.java:115)
I/TestRunner(2443):     at junit.framework.TestResult.runProtected(TestResult.java:133)
I/TestRunner(2443):     at junit.framework.TestResult.run(TestResult.java:118)
I/TestRunner(2443):     at junit.framework.TestCase.run(TestCase.java:124)
I/TestRunner(2443):     at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:190)
I/TestRunner(2443):     at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:175)
I/TestRunner(2443):     at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:555)
I/TestRunner(2443):     at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1584)
I/TestRunner(2736): Caused by: java.lang.IllegalArgumentException: A SPI class of type org.apache.lucene.codecs.Codec with name 'Lucene42' does not exist. You need to add the corresponding JAR file supporting this SPI to your classpath.The current classpath supports the following names: []
I/TestRunner(2736):     at org.apache.lucene.util.NamedSPILoader.lookup(NamedSPILoader.java:109)
I/TestRunner(2736):     at org.apache.lucene.codecs.Codec.forName(Codec.java:95)
I/TestRunner(2736):     at org.apache.lucene.codecs.Codec.<clinit>(Codec.java:122)
I/TestRunner(2736):     ... 19 more

----结束异常-----

----- end exception -----

推荐答案

谷歌搜索变成了一些有趣的结果。

Googling turns up some interesting results.

<一个href="https://issues.apache.org/jira/browse/LUCENE-4204">https://issues.apache.org/jira/browse/LUCENE-4204

根据上述问题,在Android APK建设者消除在META-INF / services目录,这是需要通过Lucene的一些文件。他们提出了一些解决方法,比如通过完成APK构建完成后的一些Ant任务从Lucene的罐子添加必要的文件直接到APK。只是要小心,因为一些lucene的罐子使用的META-INF / services目录中相同的文件,你可能会覆盖它们uneccessarily。

According to the issue above, the Android APK builder removes some files in the META-INF/services directory, which is required by Lucene. They suggest some workarounds, like adding the necessary files from the lucene jars directly to the APK via some ant tasks done after the APK builder is done. Just be careful, since some lucene jars use the same files in the META-INF/services directory, and you may overwrite them uneccessarily.

我真的建议你使用android Maven插件,因为他们已经应用了修复这个已经(见<一href="https://$c$c.google.com/p/maven-android-plugin/issues/detail?id=97">https://$c$c.google.com/p/maven-android-plugin/issues/detail?id=97).只需使用插件的最新版本(或以上3.2.1任何版本)。

I would actually suggest that you use the android maven plugin, as they have applied a fix for this already (see https://code.google.com/p/maven-android-plugin/issues/detail?id=97). Just use the latest version of the plugin (or any version above 3.2.1).

这篇关于java.lang.NoClassDefFoundError的:组织/阿帕奇/ Lucene的/ codeCS / codeC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆