You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by blach <st...@gmail.com> on 2014/05/07 00:32:51 UTC

Solrj problem

Hello, I'm struggling to retreive some data from my localhost Solr from an
Android Application. but i'm still having the same error.

/05-06 18:22:09.036: E/AndroidRuntime(1628): java.lang.NoSuchMethodError:
org.apache.http.conn.scheme.Scheme.<init>
05-06 18:22:09.036: E/AndroidRuntime(1628): 	at
org.apache.http.impl.conn.SchemeRegistryFactory.createSystemDefault(SchemeRegistryFactory.java:83)
05-06 18:22:09.036: E/AndroidRuntime(1628): 	at
org.apache.http.impl.client.SystemDefaultHttpClient.createClientConnectionManager(SystemDefaultHttpClient.java:121)
05-06 18:22:09.036: E/AndroidRuntime(1628): 	at
org.apache.http.impl.client.AbstractHttpClient.getConnectionManager(AbstractHttpClient.java:221)/

I'm using these Jars : 
- Commons-io-2.1.jar
- httpclient-4.3.1.jar
- httpcore-4.3.jar
- jcl-over-slf4j-1.6.6.jar
- jul-to-slf4j-1.6.6.jar
- log4j-1.2.16.jar
- slf4j-api-1.6.6.jar
- slf4j-log4j12-1.6.6.jar
- solr-solrj-4.8.0jar


and this is the code I wrote :
/package com.example.secondapp;

import java.net.MalformedURLException;

import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.HttpSolrServer;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.SolrDocumentList;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends Activity {

	Button btn1;
	EditText etxt1;
	
	public void RunIt() throws MalformedURLException, SolrServerException 
	{
		String urlString = "http://localhost:8983/solr/collection1";
    	
    	SolrServer solr = new HttpSolrServer(urlString);
		
    	SolrQuery parameters = new SolrQuery();
    	
    	parameters.set("qt", "/select");
		parameters.set("q", "mem");
		
		QueryResponse response = solr.query(parameters);
		SolrDocumentList list = response.getResults();
		
		
		   // for (int i = 0; i < list.size(); ++i) {
		    
		     // etxt1.setText((CharSequence) list.get(i));
		    //}
		
	}
	
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        btn1=(Button)findViewById(R.id.button1);
        etxt1=(EditText)findViewById(R.id.editText1);
        
        
        btn1.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				
				
				etxt1.setText("a fin111");
				
				
				try {
					RunIt();
				} catch (MalformedURLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				} catch (SolrServerException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				
				
			}
		});
            }
}/


can anyone tell me the mistake
thanks.




--
View this message in context: http://lucene.472066.n3.nabble.com/Solrj-problem-tp4135030.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Solrj problem

Posted by blach <st...@gmail.com>.
I have added the dependency 
<dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>[4.3.1]</version>
        </dependency>
    <dependency>


but still giving me the same error.



--
View this message in context: http://lucene.472066.n3.nabble.com/Solrj-problem-tp4135030p4135047.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Solrj problem

Posted by blach <st...@gmail.com>.
any solution please :)



--
View this message in context: http://lucene.472066.n3.nabble.com/Solrj-problem-tp4135030p4135046.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Solrj problem

Posted by blach <st...@gmail.com>.
Hello and thank shawn,
How can I make sure that my jar is in the classpath at runtime?



--
View this message in context: http://lucene.472066.n3.nabble.com/Solrj-problem-tp4135030p4135038.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Solrj problem

Posted by blach <st...@gmail.com>.
SOLVED,

I didn't use SOLRJ, just normal Httpclient methodes + asynktask



HttpClient client = new DefaultHttpClient();
			 
			 URI uri = new URI(params[0]);
			 
			 HttpGet Gett = new HttpGet(uri);
			 
			 HttpResponse response= client.execute(Gett);
			 
			 InputStream stream = response.getEntity().getContent();
			 
			 reader = new BufferedReader(new InputStreamReader(stream));
			 
			 StringBuffer buffer = new StringBuffer("");
			 String line="";
			 String newline=System.getProperty("line.separator");
			 
			 while ((line= reader.readLine())!=null)
			 {
				 buffer.append(line + newline);
			 }
			 reader.close();
			 
			 data= buffer.toString();
			 return data;



--
View this message in context: http://lucene.472066.n3.nabble.com/Solrj-problem-tp4135030p4135083.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Solrj problem

Posted by Shawn Heisey <so...@elyograg.org>.
On 5/7/2014 7:41 AM, blach wrote:
> according to this : https://issues.apache.org/jira/browse/SOLR-5590
> 
> I understand that solrj is still depends on the old httpclient shipped with
> android tools, and this is my problem too. KARL has made an patch, could you
> please explain what that patch for, 

I committed this patch to Solr.  It upgraded the HttpClient jars used in
Solr to 4.3.1.

This change reached users with the 4.7.0 release.  No code changes were
required -- Solr and SolrJ were already compatible with the newer
HttpClient version.  It should also work with HttpClient 4.2.x, as well
as the newest release.

Thanks,
Shawn


Re: Solrj problem

Posted by blach <st...@gmail.com>.
Hello Shawn,
according to this : https://issues.apache.org/jira/browse/SOLR-5590

I understand that solrj is still depends on the old httpclient shipped with
android tools, and this is my problem too. KARL has made an patch, could you
please explain what that patch for, 

how can I use it in to solve my problem?



--
View this message in context: http://lucene.472066.n3.nabble.com/Solrj-problem-tp4135030p4135048.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Solrj problem

Posted by Shawn Heisey <so...@elyograg.org>.
On 5/6/2014 4:32 PM, blach wrote:
> Hello, I'm struggling to retreive some data from my localhost Solr from an
> Android Application. but i'm still having the same error.
>
> /05-06 18:22:09.036: E/AndroidRuntime(1628): java.lang.NoSuchMethodError:
> org.apache.http.conn.scheme.Scheme.<init>
> 05-06 18:22:09.036: E/AndroidRuntime(1628): 	at
> org.apache.http.impl.conn.SchemeRegistryFactory.createSystemDefault(SchemeRegistryFactory.java:83)
> 05-06 18:22:09.036: E/AndroidRuntime(1628): 	at
> org.apache.http.impl.client.SystemDefaultHttpClient.createClientConnectionManager(SystemDefaultHttpClient.java:121)
> 05-06 18:22:09.036: E/AndroidRuntime(1628): 	at
> org.apache.http.impl.client.AbstractHttpClient.getConnectionManager(AbstractHttpClient.java:221)/
>
> I'm using these Jars : 
> - Commons-io-2.1.jar
> - httpclient-4.3.1.jar
> - httpcore-4.3.jar
> - jcl-over-slf4j-1.6.6.jar
> - jul-to-slf4j-1.6.6.jar
> - log4j-1.2.16.jar
> - slf4j-api-1.6.6.jar
> - slf4j-log4j12-1.6.6.jar
> - solr-solrj-4.8.0jar

The class/method that it says it can't find is in httpclient-4.3.1.jar. 
I think there are two possibilities here:  1) This jar is not in the
classpath at runtime.  2) You have a different version of httpclient in
your classpath that does not a method with a precise match on the signature.

Thanks,
Shawn