简体   繁体   English

创建新的lucene索引没有找到类错误

[英]creating new lucene index no class found error

i'm using lucene 4.0 and i want to create a new indexWriter in this way: 我正在使用lucene 4.0,我想以这种方式创建一个新的indexWriter

IndexWriter index = LuceneUtils.createIndexWriter(indexPath, true);

(it worked using lucene 3.6) where indexPath is a String with the path of the index. (它使用indexPath 3.6进行了工作),其中indexPath是带有索引路径的String I got this error: 我收到此错误:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/lucene/analysis/SimpleAnalyzer
at lucene.IndexCreator.<init>(IndexCreator.java:25)
at main.Main.main(Main.java:72)
Caused by: java.lang.ClassNotFoundException: org.apache.lucene.analysis.SimpleAnalyzer
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 2 more

i have read that i need to add lucene-analyzers-common-4.0.0.jar to the project besides lucene-core-4.0.0.jar , but i get the same error. 我已经读到我需要将lucene-analyzers-common-4.0.0.jar到项目中,除了lucene-core-4.0.0.jar ,但是我得到了同样的错误。 as a matter of fact the path of SimpleAnalyzer.class inside lucene-analyzers-common-4.0.0.jar is not org.apache.lucene.analysis.SimpleAnalyzer but org.apache.lucene.analysis.core.SimpleAnalyzer . 实际上, lucene-analyzers-common-4.0.0.jarSimpleAnalyzer.class路径不是org.apache.lucene.analysis.SimpleAnalyzer而是org.apache.lucene.analysis.core.SimpleAnalyzer

It looks like you might have a 3.6 jar in your class path. 看来您的课程路径中可能有3.6个jar。 Can you verify that an older version isn't being pulled in, possibly by transitive dependencies? 您可以验证是否可能由于传递依赖项而引入了旧版本吗?

You have an older version of lucene-core jar in your project. 您的项目中具有较旧版本的lucene-core jar The path for class SimpleAnalyzer in previous versions was org.apache.lucene.analysis.SimpleAnalyzer . 先前版本中类SimpleAnalyzer的路径是org.apache.lucene.analysis.SimpleAnalyzer During compile time the system is able finds SimpleAnalyzer on that path. 在编译期间,系统可以在该路径上找到SimpleAnalyzer But during runtime it refers to the new version. 但是在运行时,它指的是新版本。 Now the class exists in lucene-analyzers-common-4.0.0.jar under a different path. 现在,该类存在于lucene-analyzers-common-4.0.0.jar的另一路径下。 Hence NoClassDefFoundError. 因此,NoClassDefFoundError。

You can understand it further by reading this - http://javareferencegv.blogspot.com/2013/10/debugging-javalangnoclassdeffounderror.html 您可以通过阅读以下内容进一步了解它-http://javareferencegv.blogspot.com/2013/10/debugging-javalangnoclassdeffounderror.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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