关于solr中ClassNotFoundException: solr.extraction.ExtractingRequestHandler

7 篇文章 0 订阅
6 篇文章 0 订阅

前面解决了solr部署在tomcat中报错的问题,可是再解决使用solr索引pdf,word文档的时候,又报错了:

java.lang.ClassNotFoundException: solr.extraction.ExtractingRequestHandler 。

分析原因,应该是该类所在的jar包没有包含进去,后来按照wiki :http://wiki.apache.org/solr/ExtractingRequestHandler中的要求把所有的jar包都放到项目的lib目录下,仍然不行,看来是没法加载到这个jar包。

 

于是,我直接使用solr自带的jetty服务器来测试,看看是否也有这个问题,结果是没有任何问题。于是查看配置文件:solrconfig.xml,发现其中有关于lib目录的定义:

 

<lib dir="../../contrib/extraction/lib" />
  <!-- When a regex is specified in addition to a directory, only the
       files in that directory which completely match the regex
       (anchored on both ends) will be included.
    -->
  <lib dir="../../dist/" regex="apache-solr-cell-\d.*\.jar" />
  <lib dir="../../dist/" regex="apache-solr-clustering-\d.*\.jar" />
  <lib dir="../../dist/" regex="apache-solr-dataimporthandler-\d.*\.jar" />

  <!-- If a dir option (with or without a regex) is used and nothing
       is found that matches, it will be ignored
    -->
  <lib dir="../../contrib/clustering/lib/" />

  仔细分析这段xml代码,会发现在jetty中测试时,是可以找到那些对应的jar包,但是我是直接复制的conf和data目录到tomcat中solr目录下的,没做任何修改,于是就会出现找不到jar。想到这里,于是就把contrib和dist目录拷贝到tomcat中的solr目录下,然后修改其配置文件solrconfig.xml为:

 

<lib dir="contrib/extraction/lib" />
  <!-- When a regex is specified in addition to a directory, only the
       files in that directory which completely match the regex
       (anchored on both ends) will be included.
    -->
  <lib dir="dist/" regex="apache-solr-cell-\d.*\.jar" />
  <lib dir="dist/" regex="apache-solr-clustering-\d.*\.jar" />
  <lib dir="dist/" regex="apache-solr-dataimporthandler-\d.*\.jar" />

  <!-- If a dir option (with or without a regex) is used and nothing
       is found that matches, it will be ignored
    -->
  <lib dir="contrib/clustering/lib/" />

  注意,这些目录的起始位置是solr.solr.home。

在这样修改以后,再次运行测试程序,一切ok。

 

备注:测试的代码来自于:http://wiki.apache.org/solr/ExtractingRequestHandler

测试的文档为solr中docs目录下的tutorial.html文件

最后在地址栏中输入:http://localhost:8080/solr/select?q=attr_content:tutorial 即可看到结果

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值