Thursday, January 10, 2013

unable to resolve class org.apache.solr.client.solrj.impl.CommonsHttpSolrServer



[root@nmk-centos-60-3 samples]# groovy bugadd.groovy 7603.xml



org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
/opt/bugs/sources/samples/bugadd.groovy: 4: unable to resolve class org.apache.solr.client.solrj.impl.CommonsHttpSolrServer
 @ line 4, column 1.
   import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer
   ^

1 error

[root@nmk-centos-60-3 samples]#


The problem was that CommonsHttpSolrServer was changed to HttpSolrServer and StreamingUpdateSolrServer is now ConcurrentUpdateSolrServer as of solr 4.0.


So replace the lines 
import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer
with
import org.apache.solr.client.solrj.impl.HttpSolrServer

and

SolrServer server = new CommonsHttpSolrServer("http://10.10.80.93:8080/solr/");    
with
SolrServer server = new HttpSolrServer("http://10.10.80.93:8080/solr/");    

and you should be ready to go.