You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by ErwinZwart <er...@guruce.com> on 2013/01/08 10:02:01 UTC

java.lang.NoSuchMethodError: org.apache.http.conn.scheme.Scheme.

First of all my environment:

Android application using Eclipse
httpclient-4.2.2.jar

This is my piece of intelligent code:

public class TestPCCManagerActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

//        SchemeRegistry reg = new SchemeRegistry();
//        Scheme sch = new Scheme("http",  80,
PlainSocketFactory.getSocketFactory());
        
          PoolingClientConnectionManager cm = new
PoolingClientConnectionManager();
        
    }
}

All builds fine.

When running the application I got into the Fatal exception telling me that
org.apache.http.conn.scheme.Scheme.<init>  method is not found.

Further investigation seems that there the problem is when a new Scheme
object is created. So I added the code (commented out in the example above)
which is used inside the PoolingClientConnectionManager class:

        SchemeRegistry reg = new SchemeRegistry();
        Scheme sch = new Scheme("http",  80,
PlainSocketFactory.getSocketFactory());

I am getting an compile error telling me:

<http://httpcomponents.10934.n7.nabble.com/file/n18698/error.png> 

Searchiing the documentation it seems that this constructor is used for
library 4.2.2. However the error tels met that it expects: new
Scheme("http",  PlainSocketFactory.getSocketFactory(). 80);
but this is, again according to the documentation, 4.1 and is deprecated.

documentation taken from:
http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/conn/scheme/Scheme.html

<http://httpcomponents.10934.n7.nabble.com/file/n18698/scheme.png> 

I have absolutely  no idea. I also rebuilded the httpclient source code
cause the code seems ok, but that did not help,

What am I missing here
help...





--
View this message in context: http://httpcomponents.10934.n7.nabble.com/java-lang-NoSuchMethodError-org-apache-http-conn-scheme-Scheme-init-tp18698.html
Sent from the HttpClient-User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: java.lang.NoSuchMethodError: org.apache.http.conn.scheme.Scheme.

Posted by ErwinZwart <er...@guruce.com>.
Many thanks for your response Oleg,

That was indeed the problem. I am using the library suggested and it all
works now,

Many thanks!



--
View this message in context: http://httpcomponents.10934.n7.nabble.com/java-lang-NoSuchMethodError-org-apache-http-conn-scheme-Scheme-init-tp18698p18727.html
Sent from the HttpClient-User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: java.lang.NoSuchMethodError: org.apache.http.conn.scheme.Scheme.

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Tue, 2013-01-08 at 01:02 -0800, ErwinZwart wrote:
> First of all my environment:
> 
> Android application using Eclipse
> httpclient-4.2.2.jar
> 
> This is my piece of intelligent code:
> 
> public class TestPCCManagerActivity extends Activity {
>     /** Called when the activity is first created. */
>     @Override
>     public void onCreate(Bundle savedInstanceState) {
>         super.onCreate(savedInstanceState);
>         setContentView(R.layout.main);
> 
> //        SchemeRegistry reg = new SchemeRegistry();
> //        Scheme sch = new Scheme("http",  80,
> PlainSocketFactory.getSocketFactory());
>         
>           PoolingClientConnectionManager cm = new
> PoolingClientConnectionManager();
>         
>     }
> }
> 
> All builds fine.
> 
> When running the application I got into the Fatal exception telling me that
> org.apache.http.conn.scheme.Scheme.<init>  method is not found.
> 
> Further investigation seems that there the problem is when a new Scheme
> object is created. So I added the code (commented out in the example above)
> which is used inside the PoolingClientConnectionManager class:
> 
>         SchemeRegistry reg = new SchemeRegistry();
>         Scheme sch = new Scheme("http",  80,
> PlainSocketFactory.getSocketFactory());
> 
> I am getting an compile error telling me:
> 
> <http://httpcomponents.10934.n7.nabble.com/file/n18698/error.png> 
> 
> Searchiing the documentation it seems that this constructor is used for
> library 4.2.2. However the error tels met that it expects: new
> Scheme("http",  PlainSocketFactory.getSocketFactory(). 80);
> but this is, again according to the documentation, 4.1 and is deprecated.
> 
> documentation taken from:
> http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/conn/scheme/Scheme.html
> 
> <http://httpcomponents.10934.n7.nabble.com/file/n18698/scheme.png> 
> 
> I have absolutely  no idea. I also rebuilded the httpclient source code
> cause the code seems ok, but that did not help,
> 
> What am I missing here
> help...
> 

Android ships with a very outdated ALPHA version of HttpClient 4.0. One
cannot use newer versions of HttpClient on Android without moving all
the classes to a different namespace (org.apache.http ->
my.company.http). This is really a monumental f**kup but there is
nothing we can do about it until either Google completely removes old
HttpClient from their default Android distribution or we start producing
Android specific distribution of HttpClient (which is not likely to
happen soon).

There is already a repackaged version which you might want to try out:

http://code.google.com/p/httpclientandroidlib/

Oleg



---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org