Announcement Announcement Module
Collapse
No announcement yet.
Use Spring Social Tumblr by sdouglass with Spring 3.0.5 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Use Spring Social Tumblr by sdouglass with Spring 3.0.5

    Hi All,

    I am not sure if this is the right place to post a question regarding a Spring Social contribution, but has any one succesfully used Spring Social Tumblr (https://github.com/sdouglass/spring-social-tumblr) with spring 3.0.5? The main issues are Spring Web related (RestTemplate), but I am not able to upgrade to a more recent build.

    Thanks in advance,

    Bas Peters

  • #2
    I've not used it much at all with any version of Spring. But I'm curious: What problems are you having with Spring 3.0.5? There might be an obvious fix.

    Spring Social currently works with both Spring 3.1.x and Spring 3.0.x, but has to do some decision making in the process to decide how to deal with certain RestTemplate interceptors which are only available in Spring 3.1.x. Perhaps the Tumblr module is doing something out of sorts that makes it only work with 3.1.x.

    FWIW, when Spring Social 3.1.0 is released it will no longer support Spring 3.0.x. Just a heads-up and strong suggestion to move to Spring 3.1.x as soon as possible.

    Comment


    • #3
      Sorry for the late reply. First I cannot upgrade to 3.1 as my code is part of a standard application that relies on 3.0.5. I first tried to solve it by adding Spring Web 3.1, but that breaks the application.

      I think it is related to the TumblrTemplate implementation. It relies on org.springframework.http.client.ClientHttpRequestI nterceptor and that class was only added in 3.1. While browsing the code of some other Spring Social implementations I saw they have a check if there is interceptor support and if not (pre 3.1) use a org.springframework.http.client.ClientHttpRequestF actory implementation to add the Authorization header. I added this logic to the TumblrTemplate class to give it a try, but it does not solve the issue.

      The exception I receive in the end is I guess related to the RestTemplate implementation that also changed significantly between 3.0.5 and 3.1:

      Exception in thread "main" org.springframework.web.client.ResourceAccessExcep tion: I/O error: Unrecognized field "meta" (Class org.springframework.social.tumblr.api.Followers), not marked as ignorable
      at [Source: org.apache.http.conn.EofSensorInputStream@50988; line: 1, column: 10] (through reference chain: org.springframework.social.tumblr.api.Followers["meta"]); nested exception is org.codehaus.jackson.map.exc.UnrecognizedPropertyE xception: Unrecognized field "meta" (Class org.springframework.social.tumblr.api.Followers), not marked as ignorable
      at [Source: org.apache.http.conn.EofSensorInputStream@50988; line: 1, column: 10] (through reference chain: org.springframework.social.tumblr.api.Followers["meta"])
      at org.springframework.web.client.RestTemplate.doExec ute(RestTemplate.java:453)
      at org.springframework.web.client.RestTemplate.execut e(RestTemplate.java:415)
      at org.springframework.web.client.RestTemplate.getFor Object(RestTemplate.java:213)
      at org.springframework.social.tumblr.api.impl.BlogTem plate.followers(BlogTemplate.java:33)
      at org.springframework.social.tumblr.api.impl.BlogTem plate.followers(BlogTemplate.java:28)
      at com.example.publishing.tumblr.TumblrConnectionTest .execute(TumblrConnectionTest.java:39)
      at com.example.publishing.tumblr.TumblrConnectionTest .main(TumblrConnectionTest.java:14)
      Caused by: org.codehaus.jackson.map.exc.UnrecognizedPropertyE xception: Unrecognized field "meta" (Class org.springframework.social.tumblr.api.Followers), not marked as ignorable
      at [Source: org.apache.http.conn.EofSensorInputStream@50988; line: 1, column: 10] (through reference chain: org.springframework.social.tumblr.api.Followers["meta"])
      at org.codehaus.jackson.map.exc.UnrecognizedPropertyE xception.from(UnrecognizedPropertyException.java:5 3)
      at org.codehaus.jackson.map.deser.StdDeserializationC ontext.unknownFieldException(StdDeserializationCon text.java:246)
      at org.codehaus.jackson.map.deser.StdDeserializer.rep ortUnknownProperty(StdDeserializer.java:604)
      at org.codehaus.jackson.map.deser.StdDeserializer.han dleUnknownProperty(StdDeserializer.java:590)
      at org.codehaus.jackson.map.deser.BeanDeserializer.ha ndleUnknownProperty(BeanDeserializer.java:689)
      at org.codehaus.jackson.map.deser.BeanDeserializer.de serializeFromObject(BeanDeserializer.java:514)
      at org.codehaus.jackson.map.deser.BeanDeserializer.de serialize(BeanDeserializer.java:350)
      at org.codehaus.jackson.map.ObjectMapper._readMapAndC lose(ObjectMapper.java:2395)
      at org.codehaus.jackson.map.ObjectMapper.readValue(Ob jectMapper.java:1655)
      at org.springframework.http.converter.json.MappingJac ksonHttpMessageConverter.readInternal(MappingJacks onHttpMessageConverter.java:135)
      at org.springframework.http.converter.AbstractHttpMes sageConverter.read(AbstractHttpMessageConverter.ja va:154)
      at org.springframework.web.client.HttpMessageConverte rExtractor.extractData(HttpMessageConverterExtract or.java:74)
      at org.springframework.web.client.RestTemplate.doExec ute(RestTemplate.java:446)
      ... 6 more

      Bas Peters

      Comment


      • #4
        You're right...Spring Social Core does a check and uses an alternate approach if interceptors aren't available. If one of the provider-specific modules is using 3.1 stuff directly, then it won't be compatible with 3.0.x.

        In the case of Spring Social Tumblr (as is the case with most of the provider modules), it is a community-led project and not one that we directly develop. If you've not done so already, you might contact Sam Douglass and bring the problem to his attention. Even better, if you're so inclined, I encourage you to participate in social coding by forking Sam's project, making the fixes, then submitting a pull request back to him. I'm certain he'd appreciate the contribution.

        Now, back to your exception: From the stack trace I see, it appears that your fix got you past the interception problem, but now you're encountering a JSON mapping issue. The response for the followers has a "meta" property that isn't represented or explicitly ignored in the JSON mapping for Followers. That's also an easy fix: Just annotate FollowersMixin.java with @JsonIgnoreProperties(ignoreUnknown=true). Again, I suspect that Sam would appreciate the pull request. If you don't get to it, then I might tackle that one for you (by sending Sam a pull request).

        Comment


        • #5
          Hi Craig,

          Thanks for pushing me towards fixing it myself. My issues where only partly related to Spring 3.0.5. The Authorization part is fixed by adding the check if the interceptor is supported and if not use a ClientHttpRequestFactory like in Spring Core. I will submit a pull request to Sam Douglass to see if he is willing to add the 3.0.5 support.

          The JSON mapping issues were related to the use of an old Spring Social Core Library (1.0.0.RC1). That library does not provide overrides for AbstractOAuth1ApiBinding.configureRestTemplate and AbstractOAuth1ApiBinding.getJsonMessageConverter, so these where never called. When I added the calls in the AbstractOAuth1ApiBinding subclass, everything worked as expected, but I don't think Sam Douglass would like a hack like that, so I will see if the parent application can run with a later build of Spring Social. I do not know if it save, i.e. if it will break other Spring Social libraries included in the product. They are al 1.0.0.RC1 builds.

          Thanks,

          Bas Peters

          Comment

          Working...
          X