Home > Uncategorized > Solrj error with new httpclient

Solrj error with new httpclient

I refactored my codebase to use the new Apache HttpClient 4 component (from the org.apache.http.package).

This broke Solrj, which is dependent on the Apache HttpClient 3.x components. Th e resulting error was the cryptic

‘java.lang.ClassNotFoundException: org.apache.commons.httpclient.HttpException’

The fix was to reintroduce the commons-httpclient-3.1jar file, and explicitly pass in the older httpclient when creating the connection to Solrj.

import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
import org.apache.commons.httpclient.HttpClient;


HttpClient httpClient = new HttpClient();
server = new CommonsHttpSolrServer(url, httpClient);

  1. No comments yet.
  1. No trackbacks yet.