检索推文时出现java.lang.NoSuchMethodError异常

时间:2012-06-23 19:02:11

标签: spring spring-social

我正在开发一个使用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)

非常感谢任何帮助。

2 个答案:

答案 0 :(得分:2)

Spring Social似乎使用了最新版本的Jackson,版本为1.9,方法JsonNode.asLong()是版本1.9的新版本

比较1.81.9

的JavaDoc

答案 1 :(得分: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

获取最新版本