1

我已经在服务器上安装并配置了 Solr4 和 tomcat6。它工作得很好,但是当我尝试构建 DIH(数据导入处理程序)时,它给了我一个错误,我无法解决。

我将以下代码添加到我的 solrconfig.xml 文件中

<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
<lst name="defaults">
  <str name="config">/path/to/data-config.xml</str>
</lst>

我的 data-config.xml 文件如下所示

<dataConfig>
<dataSource type="FileDataSource" />
<document>
    <entity name="f" processor="FileListEntityProcessor" baseDir="/path/to/basedirectory/toxmlfiles/" fileName=".*xml" recursive="true" rootEntity="false" dataSource="null">
        <field column="plainText" name="text"/>
    </entity>
</document>

当我点击 localhost:8080/solr/ 时我​​在浏览器上遇到 浏览器中的错误 的错误我的错误日志中的错误是

       SEVERE: Unable to create core: collection1
       org.apache.solr.common.SolrException: RequestHandler init failure
       at org.apache.solr.core.RequestHandlers.initHandlersFromConfig(RequestHandlers.java:168)
       at org.apache.solr.core.SolrCore.<init>(SolrCore.java:657)
       at org.apache.solr.core.SolrCore.<init>(SolrCore.java:566)
       at org.apache.solr.core.CoreContainer.create(CoreContainer.java:850)
       at org.apache.solr.core.CoreContainer.load(CoreContainer.java:534)
       at org.apache.solr.core.CoreContainer.load(CoreContainer.java:356)
       at org.apache.solr.core.CoreContainer$Initializer.initialize(CoreContainer.java:308)
       at org.apache.solr.servlet.SolrDispatchFilter.init(SolrDispatchFilter.java:107)
       at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:295)
       at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:422)
       at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:115)
       at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3838)
       at org.apache.catalina.core.StandardContext.start(StandardContext.java:4488)
       at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
       at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
       at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526)
       at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:637)
       at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:563)
       at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:498)
       at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277)
       at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321)
       at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
       at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
       at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)
       at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
       at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
       at org.apache.catalina.core.StandardService.start(StandardService.java:516)
       at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
       at org.apache.catalina.startup.Catalina.start(Catalina.java:593)
       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:616)
       at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
       at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
    Caused by: org.apache.solr.common.SolrException: Error loading class 'org.apache.solr.handler.dataimport.DataImportHandler'
       at org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:436)
       at org.apache.solr.core.SolrCore.createInstance(SolrCore.java:469)
       at org.apache.solr.core.SolrCore.createRequestHandler(SolrCore.java:540)
       at org.apache.solr.core.RequestHandlers.initHandlersFromConfig(RequestHandlers.java:154)
    ... 34 more
    Caused by: java.lang.ClassNotFoundException: org.apache.solr.handler.dataimport.DataImportHandler
       at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
       at java.security.AccessController.doPrivileged(Native Method)
       at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
       at java.net.FactoryURLClassLoader.loadClass(URLClassLoader.java:615)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
       at java.lang.Class.forName0(Native Method)
       at java.lang.Class.forName(Class.java:264)
       at org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:420)
    ... 37 more
    Jan 31, 2013 10:44:49 AM org.apache.solr.common.SolrException log
    SEVERE: null:org.apache.solr.common.SolrException: RequestHandler init failure
       at org.apache.solr.core.RequestHandlers.initHandlersFromConfig(RequestHandlers.java:168)
       at org.apache.solr.core.SolrCore.<init>(SolrCore.java:657)
       at org.apache.solr.core.SolrCore.<init>(SolrCore.java:566)
       at org.apache.solr.core.CoreContainer.create(CoreContainer.java:850)
       at org.apache.solr.core.CoreContainer.load(CoreContainer.java:534)

你能建议我如何解决这个错误?

4

1 回答 1

6

我在 solrconfig.xml 文件中添加了以下代码行

<lib dir="../../../contrib/dataimporthandler/lib/" regex=".*\.jar" />
<lib dir="../../../dist/" regex="apache-solr-dataimporthandler-\d.*\.jar" />

确保 dist 文件夹中的 apache-solr-dataimporthandler-4.0.jar 和 apache-solr-dataimporthandler-extras-4.0.jar 文件位于正确的路径中。

不要忘记重启tomcat服务器。

这对我有用。

于 2013-01-31T16:33:48.387 回答