dmfrey
Mar 4th, 2011, 03:33 PM
I setup an an android app using Spring Mobile and Spring Android 1.0.0.M2 according to the instructions on the respective pages. These libraries are being managed by Maven, so they should be pulling the correct versions listed above.
However, when I execute my code (no compile time errors) I get a runtime error
03-04 16:22:09.036: ERROR/AndroidRuntime(6206): FATAL EXCEPTION: main
03-04 16:22:09.036: ERROR/AndroidRuntime(6206): java.lang.NoSuchMethodError: org.springframework.web.client.RestTemplate.setInt erceptors
03-04 16:22:09.036: ERROR/AndroidRuntime(6206): at org.springframework.social.oauth1.ProtectedResourc eClientFactory.create(ProtectedResourceClientFacto ry.java:37)
03-04 16:22:09.036: ERROR/AndroidRuntime(6206): at org.springframework.social.twitter.TwitterTemplate .<init>(TwitterTemplate.java:84)
03-04 16:22:09.036: ERROR/AndroidRuntime(6206): at org.openschedule.util.TwitterPrefs.getTwitterTempl ate(TwitterPrefs.java:131)
03-04 16:22:09.036: ERROR/AndroidRuntime(6206): at org.openschedule.activities.twitter.TwitterActivit y.postTweet(TwitterActivity.java:173)
03-04 16:22:09.036: ERROR/AndroidRuntime(6206): at org.openschedule.activities.twitter.TwitterActivit y.onCreate(TwitterActivity.java:74)
03-04 16:22:09.036: ERROR/AndroidRuntime(6206): at android.app.Instrumentation.callActivityOnCreate(I nstrumentation.java:1047)
03-04 16:22:09.036: ERROR/AndroidRuntime(6206): at android.app.ActivityThread.performLaunchActivity(A ctivityThread.java:2701)
03-04 16:22:09.036: ERROR/AndroidRuntime(6206): at android.app.ActivityThread.handleLaunchActivity(Ac tivityThread.java:2753)
03-04 16:22:09.036: ERROR/AndroidRuntime(6206): at android.app.ActivityThread.access$2500(ActivityThr ead.java:129)
03-04 16:22:09.036: ERROR/AndroidRuntime(6206): at android.app.ActivityThread$H.handleMessage(Activit yThread.java:2107)
03-04 16:22:09.036: ERROR/AndroidRuntime(6206): at android.os.Handler.dispatchMessage(Handler.java:99 )
03-04 16:22:09.036: ERROR/AndroidRuntime(6206): at android.os.Looper.loop(Looper.java:143)
03-04 16:22:09.036: ERROR/AndroidRuntime(6206): at android.app.ActivityThread.main(ActivityThread.jav a:4701)
03-04 16:22:09.036: ERROR/AndroidRuntime(6206): at java.lang.reflect.Method.invokeNative(Native Method)
03-04 16:22:09.036: ERROR/AndroidRuntime(6206): at java.lang.reflect.Method.invoke(Method.java:521)
03-04 16:22:09.036: ERROR/AndroidRuntime(6206): at com.android.internal.os.ZygoteInit$MethodAndArgsCa ller.run(ZygoteInit.java:868)
03-04 16:22:09.036: ERROR/AndroidRuntime(6206): at com.android.internal.os.ZygoteInit.main(ZygoteInit .java:626)
03-04 16:22:09.036: ERROR/AndroidRuntime(6206): at dalvik.system.NativeStart.main(Native Method)
I have verified that the RestTemplate code does not contain this method.
It is being called from org.springframework.social.oauth1.ProtectedResourc eClientFactory
public static RestTemplate create(String consumerKey, String consumerSecret, String accessToken, String accessTokenSecret) {
RestTemplate client = new RestTemplate();
if (interceptorsSupported) {
// favored
client.setInterceptors(new ClientHttpRequestInterceptor[] { new OAuth1RequestInterceptor(consumerKey, consumerSecret, accessToken, accessTokenSecret)}); // HERE IS THE CODE BEING CALLED.
} else {
// 3.0.x compatibility
client.setRequestFactory(new Spring30OAuth1RequestFactory(client.getRequestFact ory(), consumerKey, consumerSecret, accessToken, accessTokenSecret));
}
return client;
}
Thanks for any help.
However, when I execute my code (no compile time errors) I get a runtime error
03-04 16:22:09.036: ERROR/AndroidRuntime(6206): FATAL EXCEPTION: main
03-04 16:22:09.036: ERROR/AndroidRuntime(6206): java.lang.NoSuchMethodError: org.springframework.web.client.RestTemplate.setInt erceptors
03-04 16:22:09.036: ERROR/AndroidRuntime(6206): at org.springframework.social.oauth1.ProtectedResourc eClientFactory.create(ProtectedResourceClientFacto ry.java:37)
03-04 16:22:09.036: ERROR/AndroidRuntime(6206): at org.springframework.social.twitter.TwitterTemplate .<init>(TwitterTemplate.java:84)
03-04 16:22:09.036: ERROR/AndroidRuntime(6206): at org.openschedule.util.TwitterPrefs.getTwitterTempl ate(TwitterPrefs.java:131)
03-04 16:22:09.036: ERROR/AndroidRuntime(6206): at org.openschedule.activities.twitter.TwitterActivit y.postTweet(TwitterActivity.java:173)
03-04 16:22:09.036: ERROR/AndroidRuntime(6206): at org.openschedule.activities.twitter.TwitterActivit y.onCreate(TwitterActivity.java:74)
03-04 16:22:09.036: ERROR/AndroidRuntime(6206): at android.app.Instrumentation.callActivityOnCreate(I nstrumentation.java:1047)
03-04 16:22:09.036: ERROR/AndroidRuntime(6206): at android.app.ActivityThread.performLaunchActivity(A ctivityThread.java:2701)
03-04 16:22:09.036: ERROR/AndroidRuntime(6206): at android.app.ActivityThread.handleLaunchActivity(Ac tivityThread.java:2753)
03-04 16:22:09.036: ERROR/AndroidRuntime(6206): at android.app.ActivityThread.access$2500(ActivityThr ead.java:129)
03-04 16:22:09.036: ERROR/AndroidRuntime(6206): at android.app.ActivityThread$H.handleMessage(Activit yThread.java:2107)
03-04 16:22:09.036: ERROR/AndroidRuntime(6206): at android.os.Handler.dispatchMessage(Handler.java:99 )
03-04 16:22:09.036: ERROR/AndroidRuntime(6206): at android.os.Looper.loop(Looper.java:143)
03-04 16:22:09.036: ERROR/AndroidRuntime(6206): at android.app.ActivityThread.main(ActivityThread.jav a:4701)
03-04 16:22:09.036: ERROR/AndroidRuntime(6206): at java.lang.reflect.Method.invokeNative(Native Method)
03-04 16:22:09.036: ERROR/AndroidRuntime(6206): at java.lang.reflect.Method.invoke(Method.java:521)
03-04 16:22:09.036: ERROR/AndroidRuntime(6206): at com.android.internal.os.ZygoteInit$MethodAndArgsCa ller.run(ZygoteInit.java:868)
03-04 16:22:09.036: ERROR/AndroidRuntime(6206): at com.android.internal.os.ZygoteInit.main(ZygoteInit .java:626)
03-04 16:22:09.036: ERROR/AndroidRuntime(6206): at dalvik.system.NativeStart.main(Native Method)
I have verified that the RestTemplate code does not contain this method.
It is being called from org.springframework.social.oauth1.ProtectedResourc eClientFactory
public static RestTemplate create(String consumerKey, String consumerSecret, String accessToken, String accessTokenSecret) {
RestTemplate client = new RestTemplate();
if (interceptorsSupported) {
// favored
client.setInterceptors(new ClientHttpRequestInterceptor[] { new OAuth1RequestInterceptor(consumerKey, consumerSecret, accessToken, accessTokenSecret)}); // HERE IS THE CODE BEING CALLED.
} else {
// 3.0.x compatibility
client.setRequestFactory(new Spring30OAuth1RequestFactory(client.getRequestFact ory(), consumerKey, consumerSecret, accessToken, accessTokenSecret));
}
return client;
}
Thanks for any help.