简体   繁体   中英

Exception in thread “main” java.lang.NoClassDefFoundError: org/apache/http/NoHttpResponseException

Below code is for "Search using SolrJ". When running code this error is shown.

IDE is netbean.

public static void main(String[] args) throws MalformedURLException, SolrServerException {
**HttpSolrServer solr = new HttpSolrServer("http://localhost:8983/solr");**

SolrQuery query = new SolrQuery();
query.setQuery("sony digital camera");
query.addFilterQuery("cat:electronics","store:amazon.com");
query.setFields("id","price","merchant","cat","store");
query.setStart(0);    
query.set("defType", "edismax");

QueryResponse response = solr.query(query);
SolrDocumentList results = response.getResults();
for (int i = 0; i < results.size(); ++i) {
  System.out.println(results.get(i));
}
}

Exception in thread “main” java.lang.NoClassDefFoundError: org/apache/http/NoHttpResponseException

You are missing NoHttpResponseException class in your classpath while running the code. To resolve this, just add apache httpcore-4.0.1.jar to your classpath.

My first guess would be that you are either missing the httpcore-4.0.jar or have an old version of it, since it used on 4.0 and after.

Also check if you have it in the deployment path.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM