本文介绍了Solrj 身份验证在写入操作时失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Jetty 服务器上只有密码保护的 solr.我可以使用 solrj 从 solr 读取/访问数据:->

Just password protected solr on Jetty server. I am able to read/access data from solr using solrj :->

HttpSolrServer solr = new HttpSolrServer("http://111.111.111:8983/solr/mysolr");
   HttpClientUtil.setBasicAuth((DefaultHttpClient) solr.getHttpClient(), "admin", "akshaybhatt");

但它给了我如下的 I/O 异常.还有其他关于身份验证的例子,但我不知道如何在 Solrj 中使用身份验证.仅当我尝试更新记录(并可能添加记录,尚未测试)时才会出现以下错误

but it gives me I/O Exception as below. There are other examples on SO about authentication but I have no idea how do I use authentication in Solrj. The below error comes only when I try to update a record (and possibly add a record, not tested yet)

org.apache.solr.client.solrj.SolrServerException: IOException occured when talking to server at: http://111.111.111.138:8983/solr/mysolrcore
    at org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:507)
    at org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:199)
    at org.apache.solr.client.solrj.request.AbstractUpdateRequest.process(AbstractUpdateRequest.java:118)
    at org.apache.solr.client.solrj.SolrServer.add(SolrServer.java:116)
    at org.apache.solr.client.solrj.SolrServer.add(SolrServer.java:102)
    at UpdateSolrTesting.AddToSolr(UpdateSolrTesting.java:228)
    at UpdateSolrTesting.performaction(UpdateSolrTesting.java:141)
    at UpdateSolrTesting.main(UpdateSolrTesting.java:101)
Caused by: org.apache.http.client.ClientProtocolException
    at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:867)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:106)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57)
    at org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:395)
    ... 7 more
Caused by: org.apache.http.client.NonRepeatableRequestException: Cannot retry request with a non-repeatable request entity.
    at org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:660)
    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:486)
    at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:863)
    ... 11 more

推荐答案

类似的问题已经问过了,您可以查看以下链接以获得一些想法.

Similar question asked already, you can look at the below links to get some idea.

这篇关于Solrj 身份验证在写入操作时失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-14 12:22