我正在尝试使用 EmbeddedSolrServer 实现 Java 程序,当我运行我的程序时出现异常:
Jul 03, 2013 12:13:49 PM org.apache.solr.core.CoreContainer <init>
INFO: New CoreContainer 2120829822
Jul 03, 2013 12:13:49 PM org.apache.solr.core.CoreContainer load
INFO: Loading CoreContainer using Solr Home: '/home/usersolr/solr-4.2.1/indexation_test1/solr'
Jul 03, 2013 12:13:49 PM org.apache.solr.core.SolrResourceLoader <init>
INFO: new SolrResourceLoader for directory: '/home/usersolr/solr-4.2.1/indexation_test1/solr/'
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.lang.NoClassDefFoundError: org/apache/lucene/codecs/PostingsFormat
at org.apache.solr.core.SolrResourceLoader.reloadLuceneSPI(SolrResourceLoader.java:181)
at org.apache.solr.core.SolrResourceLoader.<init>(SolrResourceLoader.java:114)
at org.apache.solr.core.SolrResourceLoader.<init>(SolrResourceLoader.java:231)
at org.apache.solr.core.CoreContainer.load(CoreContainer.java:422)
at org.apache.solr.core.CoreContainer.load(CoreContainer.java:405)
at org.apache.solr.core.CoreContainer.<init>(CoreContainer.java:189)
at Main.Main.main(Main.java:35)
... 5 more
Caused by: java.lang.ClassNotFoundException: org.apache.lucene.codecs.PostingsFormat
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 12 more
有人已经遇到过这个例外吗?在女巫 JAR 文件中可以找到 PostingsFormat 类?
编辑(已解决):
如果你像我一样不知道在哪里可以找到需要的 jars,可以在这些路径下找到一些 jars 文件:
- solr-XXX/example/solr-webapp/webapp/WEB-INF/lib/
- solr-XXX/example/lib(特别是:servlet-api-XXjar)
希望能帮助到你 !
感谢 Marvin Emil Brach 和 Jayendra
科伦廷