clojure-solr-0.2.0和solr4

时间:2012-05-18 20:51:08

标签: solr clojure solrj

我正在尝试使用solr4(trunk nightly build)使用clojure-solr-0.2.0。我遇到以下异常:

Caused by: java.lang.RuntimeException: Invalid version or the data in not in 'javabin' format
at org.apache.solr.common.util.JavaBinCodec.unmarshal(JavaBinCodec.java:99)
at org.apache.solr.client.solrj.impl.BinaryResponseParser.processResponse(BinaryResponseParser.java:39)
at org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.request(CommonsHttpSolrServer.java:466)
at org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.request(CommonsHttpSolrServer.java:243)
at org.apache.solr.client.solrj.request.QueryRequest.process(QueryRequest.java:89)

我假设这是因为clojure-solr正在使用某些版本的solrj库来自solr3代码库,而javabin格式在版本之间发生了变化。

是否有一些简单的方法可以让它发挥作用?

编辑:

我从项目的lib文件夹中删除了solrj,并将其替换为lib/apache-solr-solrj-4.0-2012-05-15_08-20-37.jar。我希望这可以工作,因为在运行时在类路径上找到相同的类(应该)(只有在运行lein deps来获取依赖关系时才需要传递依赖(或者我推理)。结果是在运行时找不到的类:

Caused by: java.lang.ClassNotFoundException:    org.apache.solr.client.solrj.impl.CommonsHttpSolrServer
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at clojure.lang.DynamicClassLoader.findClass(DynamicClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at clojure_solr$eval1423$loading__4414__auto____1424.invoke(clojure_solr.clj:1)
at clojure_solr$eval1423.invoke(clojure_solr.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:5424)
... 95 more

问题是jar中不再存在CommonsHttpSolrServer

$ jar tf lib/apache-solr-solrj-4.0-2012-05-15_08-20-37.jar |grep Http
org/apache/solr/client/solrj/impl/HttpSolrServer$1.class
org/apache/solr/client/solrj/impl/HttpSolrServer$2.class
org/apache/solr/client/solrj/impl/HttpSolrServer$3.class
org/apache/solr/client/solrj/impl/HttpSolrServer$DeflateDecompressingEntity.class
org/apache/solr/client/solrj/impl/HttpSolrServer$GzipDecompressingEntity.class
org/apache/solr/client/solrj/impl/HttpSolrServer$UseCompressionRequestInterceptor.class
org/apache/solr/client/solrj/impl/HttpSolrServer$UseCompressionResponseInterceptor.class
org/apache/solr/client/solrj/impl/HttpSolrServer.class
org/apache/solr/client/solrj/impl/LBHttpSolrServer$1.class
org/apache/solr/client/solrj/impl/LBHttpSolrServer$Req.class
org/apache/solr/client/solrj/impl/LBHttpSolrServer$Rsp.class
org/apache/solr/client/solrj/impl/LBHttpSolrServer$ServerWrapper.class
org/apache/solr/client/solrj/impl/LBHttpSolrServer.class
$ jar tf lib/apache-solr-solrj-4.0-2012-05-15_08-20-37.jar |grep CommonsHttp
$

1 个答案:

答案 0 :(得分:1)

您很可能需要自己构建clojure-solr并修复它以使用最新的solr4。这实际上并不那么难。

  • the github project
  • 克隆它
  • lein install
  • 将其添加为主项目中的依赖项
  • 黑客并重复。