You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by wm...@cox.net on 2016/10/18 20:39:02 UTC

HttpSolrClient.Builder

What causes this?
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/impl/client/CloseableHttpClient
	at org.apache.solr.client.solrj.impl.HttpSolrClient.<init>(HttpSolrClient.java:209)
	at org.apache.solr.client.solrj.impl.HttpSolrClient$Builder.build(HttpSolrClient.java:874)

The code is:
return new HttpSolrClient.Builder(urlString).build();
After connecting to a Solr server, should I call solrServer.close();
or
should I leave the connection open until the entire index is built?

Re: HttpSolrClient.Builder

Posted by Shawn Heisey <ap...@elyograg.org>.
On 10/18/2016 2:39 PM, wmcginnis@cox.net wrote:
> What causes this?
> Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/impl/client/CloseableHttpClient
> 	at org.apache.solr.client.solrj.impl.HttpSolrClient.<init>(HttpSolrClient.java:209)
> 	at org.apache.solr.client.solrj.impl.HttpSolrClient$Builder.build(HttpSolrClient.java:874)

This is most likely caused by having multiple versions of jars on your
classpath.  You've probably got an older version of the HttpComponents
jars (httpclient, httpmime, httpcore) somewhere that's missing a class
that SolrJ needs from the newer version.  The correct jar versions can
be found included with Solr.

> The code is:
> return new HttpSolrClient.Builder(urlString).build();
> After connecting to a Solr server, should I call solrServer.close();
> or
> should I leave the connection open until the entire index is built?

The intent is that the client object will be created once and used in
the program until it stops running.  Many users *never* close the
client.  It can also be shared by multiple threads with no problems.

Thanks,
Shawn