Solr 4.10 DIH 错误

错误信息如下:

Caused by: java.lang.ClassNotFoundException: solr.DataImportHandler

错误堆栈内容为:

null:org.apache.solr.common.SolrException: Error handling 'reload' action
        at org.apache.solr.handler.admin.CoreAdminHandler.handleReloadAction(CoreAdminHandler.java:737)
        at org.apache.solr.handler.admin.CoreAdminHandler.handleRequestInternal(CoreAdminHandler.java:225)
        at org.apache.solr.handler.admin.CoreAdminHandler.handleRequestBody(CoreAdminHandler.java:188)
        at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:135)
        at org.apache.solr.servlet.SolrDispatchFilter.handleAdminRequest(SolrDispatchFilter.java:729)
        at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:258)
        at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:207)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
        at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2466)
        at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2455)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.solr.common.SolrException: Unable to reload core [bcodepot]
        at org.apache.solr.core.CoreContainer.reload(CoreContainer.java:591)
        at org.apache.solr.handler.admin.CoreAdminHandler.handleReloadAction(CoreAdminHandler.java:735)
        ... 23 more
Caused by: org.apache.solr.common.SolrException: RequestHandler init failure
        at org.apache.solr.core.SolrCore.<init>(SolrCore.java:873)
        at org.apache.solr.core.SolrCore.reload(SolrCore.java:429)
        at org.apache.solr.core.CoreContainer.reload(CoreContainer.java:586)
        ... 24 more
Caused by: org.apache.solr.common.SolrException: RequestHandler init failure
        at org.apache.solr.core.RequestHandlers.initHandlersFromConfig(RequestHandlers.java:172)
        at org.apache.solr.core.SolrCore.<init>(SolrCore.java:792)
        ... 26 more
Caused by: org.apache.solr.common.SolrException: Error loading class 'solr.DataImportHandler'
        at org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:490)
        at org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:421)
        at org.apache.solr.core.SolrCore.createInstance(SolrCore.java:543)
        at org.apache.solr.core.SolrCore.createRequestHandler(SolrCore.java:616)
        at org.apache.solr.core.RequestHandlers.initHandlersFromConfig(RequestHandlers.java:158)
        ... 27 more
Caused by: java.lang.ClassNotFoundException: solr.DataImportHandler
        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:425)
        at java.net.FactoryURLClassLoader.loadClass(URLClassLoader.java:789)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:274)
        at org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:474)
        ... 31 more

上面显示的是错误信息。

解决办法

可以到 Solr 的 dist 目录下拷贝 solr-dataimporthandler-4.10.2.jar 和 solr-dataimporthandler-extras-4.10.2.jar 到你索引目录下的 lib 目录中。

如果没有 lib 目录,你可以创建一个。