1

我正在开发一个使用 Spring Social API 访问 Twitter 帐户的应用程序。与 Twitter 的连接已成功建立。我能够检索关注者的数量、个人资料名称和朋友。当我尝试检索用户的推文时,我得到 java.lang.NoSuchMethodError 异常。

完整的堆栈跟踪是:

java.lang.NoSuchMethodError: org.codehaus.jackson.JsonNode.asLong()J
    at org.springframework.social.twitter.api.impl.TweetDeserializer.deserialize(TweetDeserializer.java:42)
    at org.springframework.social.twitter.api.impl.TweetDeserializer.deserialize(TweetDeserializer.java:37)
    at org.codehaus.jackson.map.deser.CollectionDeserializer.deserialize(CollectionDeserializer.java:116)
    at org.codehaus.jackson.map.deser.CollectionDeserializer.deserialize(CollectionDeserializer.java:93)
    at org.codehaus.jackson.map.deser.CollectionDeserializer.deserialize(CollectionDeserializer.java:25)
    at org.codehaus.jackson.map.ObjectMapper._readMapAndClose(ObjectMapper.java:2131)
    at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1455)
    at org.springframework.http.converter.json.MappingJacksonHttpMessageConverter.readInternal(MappingJacksonHttpMessageConverter.java:136)
    at org.springframework.http.converter.AbstractHttpMessageConverter.read(AbstractHttpMessageConverter.java:154)
    at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:74)
    at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:446)
    at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:415)
    at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:213)
    at org.springframework.social.twitter.api.impl.TimelineTemplate.getHomeTimeline(TimelineTemplate.java:58)
    at org.springframework.social.twitter.api.impl.TimelineTemplate.getHomeTimeline(TimelineTemplate.java:48)
    at com.mindtree.web.controller.SimpleContoller.handleRequest(SimpleContoller.java:68)
    at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:863)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:792)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:851)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:756)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Unknown Source)

任何帮助将不胜感激。

4

2 回答 2

2

看来Spring Social使用的是Jackson的最新版本,即1.9版本,方法JsonNode.asLong()是1.9版本的新方法

比较1.81.9的 JavaDoc

于 2012-06-24T02:18:56.413 回答
0

spring-social 1.0.1 和 jackson 1.9.2 没有问题。最新的 spring-social 包支持 jackson 1.9。

spring-social-core-1.0.1.RELEASE.jar
spring-social-twitter-1.0.1.RELEASE.jar
jackson-all-1.9.2.jar

询问 :

List<Tweet> tweets = twitterApi.timelineOperations().getHomeTimeline();

您可以从以下网址获取最新版本:http ://www.springsource.org/spring-social

于 2012-07-30T09:13:26.520 回答