DIH(Data Import Handler) for xml files is not working in Solr4

 ̄綄美尐妖づ 提交于 2019-11-28 02:18:25

问题


I have installed and configure Solr4 and tomcat6 on to the server. It works good but when I try to build the DIH(Data Import Handler) it gives me an error and I am not able to resolve.

I add the following code to my solrconfig.xml file

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

my data-config.xml file looks like as follow

<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>

The error I got on the browser when I hit localhost:8080/solr/

The error in my error log is
       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)

can you please suggest me How can I resolve this error?


回答1:


I have added following lines of code in solrconfig.xml file

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

make sure your apache-solr-dataimporthandler-4.0.jar and apache-solr-dataimporthandler-extras-4.0.jar files in the dist folder and it's in correct path.

don't forget to restart the tomcat server.

and that works for me.



来源:https://stackoverflow.com/questions/14629955/dihdata-import-handler-for-xml-files-is-not-working-in-solr4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!