Archive

Archive for September, 2011

Solrj error with new httpclient

September 6th, 2011 No comments

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);

Tags: