Announcement Announcement Module
No announcement yet.
Use Spring Social Tumblr by sdouglass with Spring 3.0.5 Page Title Module
Move Remove Collapse
Conversation Detail Module
  • 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 ( 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.


    • #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, not marked as ignorable
      at [Source: [email protected]; line: 1, column: 10] (through reference chain:["meta"]); nested exception is xception: Unrecognized field "meta" (Class, not marked as ignorable
      at [Source: [email protected]; line: 1, column: 10] (through reference chain:["meta"])
      at org.springframework.web.client.RestTemplate.doExec ute(
      at org.springframework.web.client.RestTemplate.execut e(
      at org.springframework.web.client.RestTemplate.getFor Object(
      at plate.followers(
      at plate.followers(
      at com.example.publishing.tumblr.TumblrConnectionTest .execute(
      at com.example.publishing.tumblr.TumblrConnectionTest .main(
      Caused by: xception: Unrecognized field "meta" (Class, not marked as ignorable
      at [Source: [email protected]; line: 1, column: 10] (through reference chain:["meta"])
      at xception.from( 3)
      at ontext.unknownFieldException(StdDeserializationCon
      at ortUnknownProperty(
      at dleUnknownProperty(
      at ndleUnknownProperty(
      at serializeFromObject(
      at serialize(
      at lose(
      at org.springframework.http.converter.json.MappingJac ksonHttpMessageConverter.readInternal(MappingJacks
      at org.springframework.http.converter.AbstractHttpMes va:154)
      at org.springframework.web.client.HttpMessageConverte rExtractor.extractData(HttpMessageConverterExtract
      at org.springframework.web.client.RestTemplate.doExec ute(
      ... 6 more

      Bas Peters


      • #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 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).


        • #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.


          Bas Peters