On 9/3/2015 8:11 PM, Firas Khasawneh wrote: > I am trying to use SolrHttpClient in solrj 5.3.0 but I am getting the > following execption: > > Caused by: java.lang.VerifyError: Bad return type > Exception Details: > Location: > > org/apache/solr/client/solrj/impl/HttpClientUtil.createClient(Lorg/apache/solr/common/params/SolrParams;)Lorg/apache/http/impl/client/CloseableHttpClient; > @57: areturn > Reason: > Type 'org/apache/http/impl/client/SystemDefaultHttpClient' (current > frame, stack[0]) is not assignable to > 'org/apache/http/impl/client/CloseableHttpClient' (from method signature) > Current Frame: > bci: @57 > flags: { } > locals: { 'org/apache/solr/common/params/SolrParams', > 'org/apache/solr/common/params/ModifiableSolrParams', > 'org/apache/http/impl/client/SystemDefaultHttpClient' } > stack: { 'org/apache/http/impl/client/SystemDefaultHttpClient' } > > I added httpcore-4.4.1.jar and httclient-4.4.1.jar to classpath but the issue > is still there. Any help is appreciated.
In SolrJ 5.3.0, the createClient method returns a CloseableHttpClient. It sounds like your code is trying to assign the result of the createClient method to an object of type SystemDefaultHttpClient. This is a derivative type of CloseableHttpClient. This would work if the derivation were the other direction. The compiler is saying that you cannot make this assignment. I tried to put these code lines into a SolrJ program: SystemDefaultHttpClient sc; sc = HttpClientUtil.createClient(someParams); After making sure all the imports were present, Eclipse did NOT like this code, saying "Type mismatch: cannot convert from CloseableHttpClient to SystemDefaultHttpClient". Compatible types for the target object include "HttpClient" and "CloseableHttpClient". Thanks, Shawn