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

15,284 views
Skip to first unread message

Martijn van Iersel

unread,
Oct 9, 2011, 7:48:07 AM10/9/11
to ektorp-discuss
Hi,

Could you please help me with a problem I'm having with Ektorp? I'm
following the reference documentation, and I already have a problem
with the first step, initializing a HttpClient.

This is my code:

public class TestCase
{
public static void main(String[] args) throws MalformedURLException
{
HttpClient client = new StdHttpClient.Builder()
.url("http://localhost:5984")
.build();
}
}


With that code I get the following exception:

Exception in thread "main" java.lang.NoSuchMethodError:
org.apache.http.conn.scheme.Scheme.<init>(Ljava/lang/String;ILorg/
apache/http/conn/scheme/SchemeSocketFactory;)V
at org.ektorp.http.StdHttpClient
$Builder.configureScheme(StdHttpClient.java:285)
at org.ektorp.http.StdHttpClient
$Builder.configureConnectionManager(StdHttpClient.java:236)
at org.ektorp.http.StdHttpClient
$Builder.configureClient(StdHttpClient.java:309)
at org.ektorp.http.StdHttpClient$Builder.build(StdHttpClient.java:
429)
at nl.helixsoft.ektorptest.TestCase.main(TestCase.java:14)

I'm using ektorp from today's git, with the following dependencies:

commons-codec-1.4.jar
commons-io-2.0.1.jar
commons-logging-1.1.1.jar
httpclient-4.1.1.jar
httpclient-cache-4.1.1.jar
httpcore-4.1.jar
jackson-core-asl-1.8.4.jar
jackson-mapper-asl-1.8.4.jar
joda-time-1.6.2.jar
junit-4.8.2.jar
mockito-all-1.8.5.jar
slf4j-api-1.6.1.jar
slf4j-simple-1.6.1.jar

I also tried changing the httpclient version to 4.1.2 but that didn't
help. What am I doing wrong? Any suggestions how to troubleshoot this
would be very welcome.

thanks in advance,
Martijn

Henrik Lundgren

unread,
Oct 10, 2011, 7:42:36 AM10/10/11
to ektorp-...@googlegroups.com
It looks like you have an old version of http client on your classpath. (4.0.0?)
Verify that the classpath only contains httpclient-4.1.1.jar

/Henrik

Marc Esher

unread,
Oct 10, 2011, 8:33:48 PM10/10/11
to ektorp-discuss
Hi Henrik,

I'm hitting the same error, though in an Android project. I'm using
ektorp 1.2.1, and I've tried httpclient 4.1.1 and 4.1.2.

It's throwing:

10-10 20:23:22.201: ERROR/AndroidRuntime(6503):
java.lang.NoSuchMethodError: org.apache.http.conn.scheme.Scheme.<init>
10-10 20:23:22.201: ERROR/AndroidRuntime(6503): at
org.ektorp.http.StdHttpClient
$Builder.configureScheme(StdHttpClient.java:289)
10-10 20:23:22.201: ERROR/AndroidRuntime(6503): at
org.ektorp.http.StdHttpClient
$Builder.configureConnectionManager(StdHttpClient.java:232)
10-10 20:23:22.201: ERROR/AndroidRuntime(6503): at
org.ektorp.http.StdHttpClient
$Builder.configureClient(StdHttpClient.java:312)
10-10 20:23:22.201: ERROR/AndroidRuntime(6503): at
org.ektorp.http.StdHttpClient$Builder.build(StdHttpClient.java:433)


Prior to that, I get this rather nasty business (below). I'm new to
Android dev so perhaps this is all run of the mill.

Thoughts?

Thanks!

Marc



10-10 20:23:22.107: INFO/dalvikvm(6503): Could not find method
org.apache.http.conn.ssl.SSLSocketFactory.<init>, referenced from
method org.ektorp.http.StdHttpClient$Builder.configureScheme
10-10 20:23:22.107: WARN/dalvikvm(6503): VFY: unable to resolve direct
method 3603: Lorg/apache/http/conn/ssl/SSLSocketFactory;.<init>
(Ljavax/net/ssl/SSLContext;Lorg/apache/http/conn/ssl/
X509HostnameVerifier;)V
10-10 20:23:22.107: DEBUG/dalvikvm(6503): VFY: replacing opcode 0x70
at 0x002a
10-10 20:23:22.115: INFO/dalvikvm(6503): Could not find method
org.apache.http.conn.scheme.Scheme.<init>, referenced from method
org.ektorp.http.StdHttpClient$Builder.configureScheme
10-10 20:23:22.115: WARN/dalvikvm(6503): VFY: unable to resolve direct
method 3534: Lorg/apache/http/conn/scheme/Scheme;.<init> (Ljava/lang/
String;ILorg/apache/http/conn/scheme/SchemeSocketFactory;)V
10-10 20:23:22.115: DEBUG/dalvikvm(6503): VFY: replacing opcode 0x70
at 0x0037
10-10 20:23:22.123: INFO/dalvikvm(6503): Could not find method
org.apache.http.conn.ssl.SSLSocketFactory.<init>, referenced from
method org.ektorp.http.StdHttpClient$Builder.configureScheme
10-10 20:23:22.123: WARN/dalvikvm(6503): VFY: unable to resolve direct
method 3601: Lorg/apache/http/conn/ssl/SSLSocketFactory;.<init>
(Ljavax/net/ssl/SSLContext;)V
10-10 20:23:22.123: DEBUG/dalvikvm(6503): VFY: replacing opcode 0x70
at 0x003d
10-10 20:23:22.130: INFO/dalvikvm(6503): Could not find method
org.apache.http.conn.scheme.Scheme.<init>, referenced from method
org.ektorp.http.StdHttpClient$Builder.configureScheme
10-10 20:23:22.130: WARN/dalvikvm(6503): VFY: unable to resolve direct
method 3534: Lorg/apache/http/conn/scheme/Scheme;.<init> (Ljava/lang/
String;ILorg/apache/http/conn/scheme/SchemeSocketFactory;)V
10-10 20:23:22.130: DEBUG/dalvikvm(6503): VFY: replacing opcode 0x70
at 0x0072
10-10 20:23:22.130: DEBUG/dalvikvm(6503): VFY: dead code 0x002d-002e
in Lorg/ektorp/http/StdHttpClient$Builder;.configureScheme ()Lorg/
apache/http/conn/scheme/Scheme;
10-10 20:23:22.130: DEBUG/dalvikvm(6503): VFY: dead code 0x0040-0040
in Lorg/ektorp/http/StdHttpClient$Builder;.configureScheme ()Lorg/
apache/http/conn/scheme/Scheme;
10-10 20:23:22.130: DEBUG/dalvikvm(6503): VFY: dead code 0x0075-0075
in Lorg/ektorp/http/StdHttpClient$Builder;.configureScheme ()Lorg/
apache/http/conn/scheme/Scheme;
10-10 20:23:22.146: ERROR/dalvikvm(6503): Could not find class
'org.apache.http.impl.client.cache.CacheConfig', referenced from
method org.ektorp.http.StdHttpClient$Builder.build
10-10 20:23:22.146: WARN/dalvikvm(6503): VFY: unable to resolve new-
instance 737 (Lorg/apache/http/impl/client/cache/CacheConfig;) in Lorg/
ektorp/http/StdHttpClient$Builder;
10-10 20:23:22.146: DEBUG/dalvikvm(6503): VFY: replacing opcode 0x22
at 0x0009
10-10 20:23:22.146: DEBUG/dalvikvm(6503): VFY: dead code 0x000b-001c
in Lorg/ektorp/http/StdHttpClient$Builder;.build ()Lorg/ektorp/http/
HttpClient;
10-10 20:23:22.154: INFO/dalvikvm(6503): Could not find method
org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager.<init>,
referenced from method org.ektorp.http.StdHttpClient
$Builder.configureConnectionManager
10-10 20:23:22.154: WARN/dalvikvm(6503): VFY: unable to resolve direct
method 4385: Lorg/apache/http/impl/conn/tsccm/
ThreadSafeClientConnManager;.<init> (Lorg/apache/http/conn/scheme/
SchemeRegistry;)V
10-10 20:23:22.162: DEBUG/dalvikvm(6503): VFY: replacing opcode 0x70
at 0x0012
10-10 20:23:22.162: DEBUG/dalvikvm(6503): VFY: dead code 0x0015-0020
in Lorg/ektorp/http/StdHttpClient$Builder;.configureConnectionManager
(Lorg/apache/http/params/HttpParams;)Lorg/apache/http/conn/
ClientConnectionManager;
10-10 20:23:22.177: DEBUG/AndroidRuntime(6503): Shutting down VM
10-10 20:23:22.177: WARN/dalvikvm(6503): threadid=1: thread exiting
with uncaught exception (group=0x400208b0)
10-10 20:23:22.201: ERROR/AndroidRuntime(6503): FATAL EXCEPTION: main
10-10 20:23:22.201: ERROR/AndroidRuntime(6503):
java.lang.NoSuchMethodError: org.apache.http.conn.scheme.Scheme.<init>
10-10 20:23:22.201: ERROR/AndroidRuntime(6503): at
org.ektorp.http.StdHttpClient
$Builder.configureScheme(StdHttpClient.java:289)
10-10 20:23:22.201: ERROR/AndroidRuntime(6503): at
org.ektorp.http.StdHttpClient
$Builder.configureConnectionManager(StdHttpClient.java:232)
10-10 20:23:22.201: ERROR/AndroidRuntime(6503): at
org.ektorp.http.StdHttpClient
$Builder.configureClient(StdHttpClient.java:312)
10-10 20:23:22.201: ERROR/AndroidRuntime(6503): at
org.ektorp.http.StdHttpClient$Builder.build(StdHttpClient.java:433)



On Oct 10, 7:42 am, Henrik Lundgren <carl.henrik.lundg...@gmail.com>
wrote:
> It looks like you have an old version of http client on your classpath. (4.0.0?)
> Verify that the classpath only contains httpclient-4.1.1.jar
>
> /Henrik
>

Henrik Lundgren

unread,
Oct 11, 2011, 2:58:02 AM10/11/11
to ektorp-...@googlegroups.com
Your problem is related to the fact that android comes bundled with a
fork of http client 4.0.x.
Ektorp 1.2.1 has upgraded to 4.1.1 which is not compatoble with 4.0.x.
You could either try to use Ektorp 1.1.1 or the 1.2.2-SNAPSHOT that
comes with better android support.

/H

Marc Esher

unread,
Oct 11, 2011, 6:53:20 AM10/11/11
to ektorp-discuss
Excellent. Thanks!

On Oct 11, 2:58 am, Henrik Lundgren <carl.henrik.lundg...@gmail.com>
wrote:

Martijn van Iersel

unread,
Oct 11, 2011, 10:55:03 AM10/11/11
to ektorp-discuss
Indeed, you're right. There were stray jar files on my class path that
I hadn't noticed before. Thanks for the help.

Martijn

On Oct 10, 12:42 pm, Henrik Lundgren <carl.henrik.lundg...@gmail.com>
wrote:
> It looks like you have an old version of http client on your classpath. (4.0.0?)
> Verify that the classpath only contains httpclient-4.1.1.jar
>
> /Henrik
>

giorgio.z...@gmail.com

unread,
May 9, 2012, 5:49:44 AM5/9/12
to ektorp-...@googlegroups.com
I'm having the same exception thrown using Ektorp on embedded Jetty 7.

The Maven dependencies and the jars into the WEB-INF/lib both points to httpclient-4.1.1.jar

The funny thing is if I run the webapp within Tomcat7 it won't through any exception...

Could be that Embedded Jetty7 is using httpclient-4.0.0 ??
How could I solve this?

Henrik Lundgren

unread,
May 9, 2012, 6:12:31 AM5/9/12
to ektorp-...@googlegroups.com
I'm using jetty 7 myself without experiencing this problem.
Are you using Maven? If so, verify that there isn't another artifact
bringing in an old http client through a transitive dependency.

/Henrik

Giorgio Z

unread,
May 10, 2012, 8:22:02 AM5/10/12
to ektorp-...@googlegroups.com
I'm using Maven indeed!  

Which Jetty artifact version exactly of Jetty are you using? I'm using:

<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>7.6.0.v20120127</version>
</dependency>


From the Dependency Hierarchy tab in Eclipse it's shown that httpclient:4.1.1 is used only by org.ektorp:1.2.2 and  httpclient-cache:4.1.1
Is this the right way to check transitive dependencies right?

THANKS A LOT HENRIK!

In case you think it's useful here it comes a list of my depencies defined with the pom.xml:

<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>7.6.0.v20120127</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
<version>1.12</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
<version>1.12</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-servlet</artifactId>
<version>1.12</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.12</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
<version>1.9.6</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-jaxrs</artifactId>
<version>1.9.5</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.6</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-xc</artifactId>
<version>1.9.6</version>
</dependency>
<dependency>
<groupId>org.ektorp</groupId>
<artifactId>org.ektorp</artifactId>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
</dependency>

<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0.2</version>
</dependency>

<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>org.fusesource.restygwt</groupId>
<artifactId>restygwt</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>com.googlecode.mgwt</groupId>
<artifactId>mgwt</artifactId>
<version>1.0.2</version>
</dependency>

and here it comes a screenshot of the Depency Hierarchy tab within Eclipse:

 






On Wednesday, May 9, 2012 12:12:31 PM UTC+2, henrik.lundgren wrote:
I'm using jetty 7 myself without experiencing this problem.
Are you using Maven? If so, verify that there isn't another artifact
bringing in an old http client through a transitive dependency.

/Henrik


Henrik Lundgren

unread,
May 10, 2012, 8:36:44 AM5/10/12
to ektorp-...@googlegroups.com
I'm not sure of the jetty version right now, but I have successfully used Ektorp with jetty 6,7 and 8.
I'm pretty sure that Jetty that the classloader in Jetty first looks in WEB-INF/lib, so if the correct version is there it should work.

Your screenshot id not make it through, but you should see httpclient 4.1.1 in the Resolved Dependencies pane.

/H

Giorgio Z

unread,
May 29, 2012, 4:47:38 AM5/29/12
to ektorp-...@googlegroups.com
So I've created a new project and started adding dependencies one by one till I found the problem!

The library that goes in conflict with Ektorp is GWT. I imported GWT using the Eclipse GWT Plugin which use plain old copied jars and not Maven.
Using GWT with Maven is a terrible pain in the ass. I've tried some weeks ago and I waste a week in millions of bugs/random deleting of folders.

Do you have any idea of how resolve conflict between GWT and Ektorp?
Moving back to an older version of Ektorp would solve the problem?Which version?

Henrik thanks again for you help!

On Thursday, May 10, 2012 2:36:44 PM UTC+2, henrik.lundgren wrote:
I'm not sure of the jetty version right now, but I have successfully used Ektorp with jetty 6,7 and 8.
I'm pretty sure that Jetty that the classloader in Jetty first looks in WEB-INF/lib, so if the correct version is there it should work.

Your screenshot id not make it through, but you should see httpclient 4.1.1 in the Resolved Dependencies pane.

/H

Henrik Lundgren

unread,
May 29, 2012, 5:06:17 AM5/29/12
to ektorp-...@googlegroups.com
you could try to use the http client supplied in the org.ektorp.android module:
org.ektorp.android.http.AndroidHttpClient

it uses an older version of the apache http client.

you should be aware that the older client has some bugs that manifests
itself during high loads...

/H

Marty Schoch

unread,
Jun 24, 2012, 1:26:38 PM6/24/12
to ektorp-...@googlegroups.com
Are you using the TouchDB-Android-Ektorp adapter, or are you using the
HTTP Listener (TouchDB-Android-Listener) and connecting to that with
AndroidHttpClient?

marty

On Sun, Jun 24, 2012 at 12:04 AM, <adistants...@gmail.com> wrote:
> Marc,
>
> Running into the same error. Were you able to resolve it by changing your
> Ektorp version? At the time of your posting I believe the stable release was
> 1.2.1; I'm getting the error using 1.2.2. Fyi, I'm using TouchDB.
>
> Thanks,
> Matt

Giorgio Zamparelli

unread,
Jun 25, 2012, 3:57:44 AM6/25/12
to ektorp-...@googlegroups.com
Hi Marc,

in the end I solved the error using org.ektorp.android.http.AndroidHttpClient as Henrik suggested.

AndroidHttpClient.Builder builder = new AndroidHttpClient.Builder()
.host(host)
.port(Integer.parseInt(port));

CouchDbConnector couchDbConnector = couchdbInstance.createConnector(databaseName, true);

Henrik mentioned that:
"you should be aware that the older client has some bugs that manifests
itself during high loads..."


2012/6/24 Marty Schoch <marty....@gmail.com>

Marty Schoch

unread,
Jun 25, 2012, 2:01:18 PM6/25/12
to ektorp-...@googlegroups.com
You mentioned you're using TouchDB. If you want to use the
TouchDB-Ektorp adapter (recommended) then you should instantiate it
like:

String filesDir = getFilesDir().getAbsolutePath();
try {
server = new TDServer(filesDir);
} catch (IOException e) {
Log.e(TAG, "Error starting TDServer", e);
}
httpClient = new TouchDBHttpClient(server);
dbInstance = new StdCouchDbInstance(httpClient);

This will provide the fastest way to communicate with TouchDB because
no actual HTTP or sockets are involved. Here is the link to the WIKI
which has some more useful information:
https://github.com/couchbaselabs/TouchDB-Android/wiki/Getting-Started

If however, you want to use the TouchDB-Listener module and then use
the regular Ektorp for Android, you need to use AndroidHttpClient and
not StdHttpClient.

marty

On Sun, Jun 24, 2012 at 11:37 PM, <adistants...@gmail.com> wrote:
> The exception is thrown by the build method when I instantiate
> StdHttpClient.
>
> authClient = new StdHttpClient.Builder()
> .url("...")
> .username("xxx")
> .password("xx")
> .build();
>
> 06-24 20:36:14.986: E/AndroidRuntime(22375): java.lang.NoSuchMethodError:
> org.apache.http.conn.scheme.Scheme.<init>
> 06-24 20:36:14.986: E/AndroidRuntime(22375): at
> org.ektorp.http.StdHttpClient$Builder.configureScheme(StdHttpClient.java:283)
> 06-24 20:36:14.986: E/AndroidRuntime(22375): at
> org.ektorp.http.StdHttpClient$Builder.configureConnectionManager(StdHttpClient.java:235)
> 06-24 20:36:14.986: E/AndroidRuntime(22375): at
> org.ektorp.http.StdHttpClient$Builder.configureClient(StdHttpClient.java:306)
> 06-24 20:36:14.986: E/AndroidRuntime(22375): at
> org.ektorp.http.StdHttpClient$Builder.build(StdHttpClient.java:427)
> 06-24 20:36:14.986: E/AndroidRuntime(22375): at
> com.yourteam.SignInInit.initializeTouchhDB(SignInInit.java:189)
> 06-24 20:36:14.986: E/AndroidRuntime(22375): at
> com.yourteam.SignInInit.onActivityResult(SignInInit.java:68)
> 06-24 20:36:14.986: E/AndroidRuntime(22375): at
> android.app.Activity.dispatchActivityResult(Activity.java:4053)
> 06-24 20:36:14.986: E/AndroidRuntime(22375): at
> android.app.ActivityThread.deliverResults(ActivityThread.java:2970)
> 06-24 20:36:14.986: E/AndroidRuntime(22375): at
> android.app.ActivityThread.handleSendResult(ActivityThread.java:3026)
> 06-24 20:36:14.986: E/AndroidRuntime(22375): at
> android.app.ActivityThread.access$2000(ActivityThread.java:135)
> 06-24 20:36:14.986: E/AndroidRuntime(22375): at
> android.app.ActivityThread$H.handleMessage(ActivityThread.java:1071)
> 06-24 20:36:14.986: E/AndroidRuntime(22375): at
> android.os.Handler.dispatchMessage(Handler.java:99)
> 06-24 20:36:14.986: E/AndroidRuntime(22375): at
> android.os.Looper.loop(Looper.java:150)
> 06-24 20:36:14.986: E/AndroidRuntime(22375): at
> android.app.ActivityThread.main(ActivityThread.java:4333)
> 06-24 20:36:14.986: E/AndroidRuntime(22375): at
> java.lang.reflect.Method.invokeNative(Native Method)
> 06-24 20:36:14.986: E/AndroidRuntime(22375): at
> java.lang.reflect.Method.invoke(Method.java:507)
> 06-24 20:36:14.986: E/AndroidRuntime(22375): at
> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
> 06-24 20:36:14.986: E/AndroidRuntime(22375): at
> com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
> 06-24 20:36:14.986: E/AndroidRuntime(22375): at
> dalvik.system.NativeStart.main(Native Method)
>
>
> On Sunday, June 24, 2012 10:26:38 AM UTC-7, Marty Schoch wrote:
>>
>> Are you using the TouchDB-Android-Ektorp adapter, or are you using the
>> HTTP Listener (TouchDB-Android-Listener) and connecting to that with
>> AndroidHttpClient?
>>
>> marty
>>

shivu...@gmail.com

unread,
Oct 13, 2015, 9:27:24 AM10/13/15
to ektorp-discuss, mvani...@gmail.com

 Hi Martijn van Iersel


    These are the jar files i am using..

commons-io-2.1.jar
httpclient-4.1.3.jar
httpclient-4.2.jar
httpcore-4.1.4.jar
httpmime-4.1.3.jar
jcl-over-slf4j-1.6.4.jar
joda-time-2.4.jar
slf4j-api-1.6.4.jar
slf4j-jdk14-1.6.4.jar
solr-solrj-4.1.0.jar
wstx-asl-3.2.7.jar
zookeeper-3.4.5.jar

I also tried with these jars.finally i tried httpclient-4.5 but i am getting same ERROR.I think u got solution for this can u help me troubleshoot this.


Thanks
Shivu
Reply all
Reply to author
Forward
0 new messages