"Stub!" error on http tests using maven

952 views
Skip to first unread message

Alex

unread,
Feb 18, 2013, 10:22:57 AM2/18/13
to robol...@googlegroups.com
If I run the test using maven I get:
java.lang.RuntimeException: Stub!
    at org.apache.http.params.AbstractHttpParams.<init>(AbstractHttpParams.java:5)
    at org.apache.http.params.BasicHttpParams.<init>(BasicHttpParams.java:6)
Running from Eclipse it works fine.
(I know: it should probably be the opposite.)
I'm pretty sure it worked at one point, but I cannot identify the cause. Any idea?
Or how can I debug this?

Thanks for your help.



Tyler Schultz

unread,
Feb 18, 2013, 10:27:46 AM2/18/13
to robol...@googlegroups.com
It looks to me that Android is ahead of Apache in the classpath.






--
You received this message because you are subscribed to the Google Groups "Robolectric" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robolectric...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Alex

unread,
Feb 18, 2013, 10:48:06 AM2/18/13
to robol...@googlegroups.com
On the maven-quick-start page, it says "<!-- Make sure this is below the android dependencies -->".
If I move robolectric before Android, I get:
java.lang.NoSuchMethodError: org.apache.http.impl.client.DefaultRequestDirector.<init>(Lorg/apache/commons/logging/Log;Lorg/apache/http/protocol/HttpRequestExecutor;Lorg/apache/http/conn/ClientConnectionManager;Lorg/apache/http/ConnectionReuseStrategy;Lorg/apache/http/conn/ConnectionKeepAliveStrategy;Lorg/apache/http/conn/routing/HttpRoutePlanner;Lorg/apache/http/protocol/HttpProcessor;Lorg/apache/http/client/HttpRequestRetryHandler;Lorg/apache/http/client/RedirectHandler;Lorg/apache/http/client/AuthenticationHandler;Lorg/apache/http/client/AuthenticationHandler;Lorg/apache/http/client/UserTokenHandler;Lorg/apache/http/params/HttpParams;)V
    at org.apache.http.impl.client.AbstractHttpClient.createClientRequestDirector(AbstractHttpClient.java:660)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:625)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:576)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:554)
...

Thanks.

Tyler Schultz

unread,
Feb 18, 2013, 11:03:19 AM2/18/13
to robol...@googlegroups.com
Ah, I see. 

It still appears to me that this is a classpath problem. Care to post the contents of your pom file? It seems that Android is loading before the Apache classes somehow.

--Tyler




Alex

unread,
Feb 18, 2013, 2:44:58 PM2/18/13
to robol...@googlegroups.com
I have attached the pom along with the parent.
pom.xml
pom.xml

Tyler Schultz

unread,
Feb 20, 2013, 10:13:05 AM2/20/13
to robol...@googlegroups.com
I don't spot anything obvious from looking at the poms.

Do you see the same behavior on different machines? It used to work, have you tried doing a git bisect to find the offending commit? Have you made any environment changes that might cause a problem, rename any files, directories...

--Tyler


On Mon, Feb 18, 2013 at 11:44 AM, Alex <amag...@gmail.com> wrote:
I have attached the pom along with the parent.

Alex

unread,
Feb 22, 2013, 8:42:13 AM2/22/13
to Robolectric
Now I have the same behaviour on different machines (Ubuntu, Windows).
Unfortunately, the project was not added to Jenkins at that time, so I
don't have a green build.
Bisect did not reveal anything. Anyway, I'm starting to have doubts
whether the build worked using maven (for this test class). This is a
legacy library that I'm adding unit tests to it. Some unit tests work
ok (like the ones depending on ConnectivityManager, SQLiteDatabase,
Robolectric.Reflection.setFinalStaticField), while only the ones
depending on http fail.
The Test Classpath is:
target/test-classes
target/classes
.m2/repository/com/google/android/android/4.1/android-4.1.jar
.m2/repository/com/google/android/android-test/4.1/android-
test-4.1.jar
.m2/repository/com/google/android/maps/maps/7_r1/maps-7_r1.jar
.m2/repository/com/pivotallabs/robolectric/1.2/robolectric-1.2.jar
.m2/repository/org/objenesis/objenesis/1.0/objenesis-1.0.jar
.m2/repository/org/xerial/sqlite-jdbc/3.7.2/sqlite-jdbc-3.7.2.jar
.m2/repository/org/javassist/javassist/3.14.0-GA/javassist-3.14.0-
GA.jar
.m2/repository/commons-logging/commons-logging/1.1.1/commons-
logging-1.1.1.jar
.m2/repository/commons-codec/commons-codec/1.3/commons-codec-1.3.jar
.m2/repository/org/apache/httpcomponents/httpclient/4.0.3/
httpclient-4.0.3.jar
.m2/repository/org/apache/httpcomponents/httpcore/4.0.1/
httpcore-4.0.1.jar
.m2/repository/com/google/android/support-v4/r6/support-v4-r6.jar
.m2/repository/org/hamcrest/hamcrest-core/1.2/hamcrest-core-1.2.jar
.m2/repository/junit/junit/4.8.2/junit-4.8.2.jar

I don't know how robolectric is managing the class loading, but
according to this classpath and java2 classloading style, the Android
classes will be loaded first.

Any other suggestion?
Thanks.

Ilya Kogan

unread,
Mar 19, 2014, 10:15:56 AM3/19/14
to robol...@googlegroups.com
Hi Alex,

Have you solved the issue since?

Haakon Gjersvik Eriksen

unread,
Mar 19, 2014, 11:00:21 AM3/19/14
to robol...@googlegroups.com

You need to make sure you're running the right version of JUnit. Try moving the junit dependency ahead of your android dependency.
Reply all
Reply to author
Forward
0 new messages