Announcement Announcement Module
Collapse
No announcement yet.
LinkedInTemplate template jackson serialization error Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • LinkedInTemplate template jackson serialization error

    Hi Im trying to connect to linkedin I already manage to connect to twitter so I followed the same aproach and every worked fine until i tryed to create the LinkedInTemplate.

    Here is a sniped of my when the access token is retrieved.

    public static void linkedin(OAuthToken anyAccess)
    {

    LinkedIn linkedin = new LinkedInTemplate(
    SpringPropertiesUtil.getProperty("linkedin.consume rKey"),
    SpringPropertiesUtil.getProperty("linkedin.consume rSecret"),
    anyAccess.getValue(),
    anyAccess.getSecret());
    }

    this is the error that I received when trying to build the LinkedInTemplate.

    Caused by: java.lang.NoSuchMethodError: org.codehaus.jackson.map.SerializationConfig.withS erializationInclusion(Lorg/codehaus/jackson/map/annotate/JsonSerialize$InclusionLorg/codehaus/jackson/map/SerializationConfig;
    at org.springframework.social.linkedin.api.impl.Linke dInTemplate.registerLinkedInJsonModule(LinkedInTem plate.java:103)
    at org.springframework.social.linkedin.api.impl.Linke dInTemplate.<init>(LinkedInTemplate.java:62)
    at social.AccountsPersistanceConfig.linkedin(Accounts PersistanceConfig.java:125)



    and this is my connectionFactoryConfiguration
    <bean id="connectionFactoryLocator"
    class="org.springframework.social.connect.support. ConnectionFactoryRegistry">
    <property name="connectionFactories">
    <list>
    <bean
    class="org.springframework.social.facebook.connect .FacebookConnectionFactory">
    <constructor-arg name="clientId" value="${facebook.clientId}" />
    <constructor-arg name="clientSecret" value="${facebook.clientSecret}" />
    </bean>
    <bean
    class="org.springframework.social.twitter.connect. TwitterConnectionFactory">
    <constructor-arg name="consumerKey" value="${twitter.consumerKey}" />
    <constructor-arg name="consumerSecret" value="${twitter.consumerSecret}" />
    </bean>
    <bean
    class="org.springframework.social.linkedin.connect .LinkedInConnectionFactory">
    <constructor-arg name="consumerKey" value="${linkedin.consumerKey}" />
    <constructor-arg name="consumerSecret" value="${linkedin.consumerSecret}" />
    </bean>
    </list>
    </property>
    </bean>

    Facebook and twitter work without problems.
    Am I doing something wrong? how can I solve the problem?

    Thanks =)
    Last edited by iturpablo; Jan 4th, 2012, 04:01 PM.

  • #2
    From the looks of the exception, it would seem that something is out of sorts with regard to the Jackson dependency. Which version of Jackson is in your classpath? For code that I know to work with the LinkedIn module, I have Jackson 1.9.2 in the classpath.

    Specifically, it's complaining about the withSerializationInclusion() method on the SerializationConfig class. That method is used to keep null values from being serialized into the JSON sent to the LinkedIn API and was added in version 1.9 of Jackson. So, if you're using an older version of Jackson, then that might explain it.

    Comment


    • #3
      Hi, I thought that too, that it might be a problem of jackson version. Im using maven this is my pom
      <!--Spring Social-->
      <dependency>
      <groupId>org.springframework.social</groupId>
      <artifactId>spring-social-core</artifactId>
      <version>1.0.1.RELEASE</version>
      </dependency>
      <dependency>
      <groupId>org.springframework.social</groupId>
      <artifactId>spring-social-web</artifactId>
      <version>1.0.1.RELEASE</version>
      </dependency>
      <!--Twitter-->
      <dependency>
      <groupId>org.springframework.social</groupId>
      <artifactId>spring-social-twitter</artifactId>
      <version>1.0.0.RELEASE</version>
      </dependency>
      <!--FaceBook-->
      <dependency>
      <groupId>org.springframework.social</groupId>
      <artifactId>spring-social-facebook</artifactId>
      <version>1.0.0.RELEASE</version>
      </dependency>
      <!--Linkedin -->
      <dependency>
      <groupId>org.springframework.social</groupId>
      <artifactId>spring-social-linkedin</artifactId>
      <version>1.0.0.M4</version>
      <!-- <version>1.0.0.BUILD-SNAPSHOT</version> -->
      </dependency>
      <dependency>
      <groupId>commons-codec</groupId>
      <artifactId>commons-codec</artifactId>
      <version>1.5</version>
      </dependency>
      <!-- <dependency> -->
      <dependency>
      <groupId>org.codehaus.jackson</groupId>
      <artifactId>jackson-mapper-asl</artifactId>
      <version>1.9.2</version>
      <scope>runtime</scope>
      </dependency>

      The image contains the real dependencies deployment
      Attachment

      I also check the deployment and it is the 1.9.2 any other idea?
      Attached Files
      Last edited by iturpablo; Jan 4th, 2012, 05:42 PM.

      Comment


      • #4
        Hi after the last reply I debug the LinkedIn project and fails in the class LinkedInTemplate in the following function.

        /*
        * Have to register custom interceptor to
        * set "x-li-format: "json" header as
        * otherwise we appear to get error from linkedin
        * which suggests its expecting xml rather than json.
        * API appears to ignore Content-Type header
        */
        private void registerJsonFormatInterceptor() {
        List<ClientHttpRequestInterceptor> interceptors = getRestTemplate().getInterceptors();
        interceptors.add(new JsonFormatInterceptor());
        }

        I read the function comment but dont know how to do this, any ideas?

        Also I'am not using spring-mvc Im using jsf with out spring mvc. I looked this class in your github and its different

        RestTemplate restTemplate = getRestTemplate();
        if (interceptorsSupported) {
        List<ClientHttpRequestInterceptor> interceptors = restTemplate.getInterceptors();
        interceptors.add(new JsonFormatInterceptor());
        } else {
        // for Spring 3.0.x where interceptors aren't supported
        ClientHttpRequestFactory originalRequestFactory = restTemplate.getRequestFactory();
        JsonFormatHeaderRequestFactory newRequestFactory = new JsonFormatHeaderRequestFactory(originalRequestFact ory);
        restTemplate.setRequestFactory(newRequestFactory);
        }
        is it posible that the patch fix my problem?
        Last edited by iturpablo; Jan 4th, 2012, 06:06 PM.

        Comment


        • #5
          Well, it's very clear from the exception that the problem is that the withSerializationInclusion() method can't be found. If you say that it's 1.9.2, then that method should be there.

          If it were my code and I had access to dig deeper, I'd start by looking for a few things:
          - Is there more than one version of Jackson in the deployment. Shouldn't be, but I've seen this kinda thing happen when there are other versions of a library alongside the one you really want.
          - If there aren't other versions, then I'd be inclined to crack open the Jackson JAR and decompile the SerializationConfig.class file to verify that the method exists.

          Within that same project in Eclipse, I might also attempt to do code-completion on that method to see if Eclipse sees it.

          Aside from that, I have no other clues.

          Comment


          • #6
            Hi, Ok ll recheck again the version of jackson

            But, what about the code modification of the registerJsonFormatInterceptor() that I commented in my previous post, I think you didnt see it because I edited at the same time your were replying (bad luck ).

            Comment


            • #7
              Hi Im really using jackson 1.9.2.

              I think the problem is that im using spring <spring.version>3.0.6.RELEASE</spring.version> and looking at the code you have in the github you patch a bug concerning this.

              Code:
              private void registerJsonFormatInterceptor() {
                     RestTemplate restTemplate = getRestTemplate();
                     if (interceptorsSupported) {
                         List<ClientHttpRequestInterceptor> interceptors = restTemplate.getInterceptors();
                         interceptors.add(new JsonFormatInterceptor());
                     } else {
                         // for Spring 3.0.x where interceptors aren't supported
                        ClientHttpRequestFactory originalRequestFactory = restTemplate.getRequestFactory();
                         JsonFormatHeaderRequestFactory newRequestFactory = new          JsonFormatHeaderRequestFactory(originalRequestFact ory);
              restTemplate.setRequestFactory(newRequestFactory);
              }
              Can you please tell me if you are gonna release any new nightly-built with this fix, so i can try it out?
              =(
              Thanks for everything

              Comment


              • #8
                Hi Habuma, I found the solution..

                The problem was already solve in your github project repository so I just download it, compile it and add it to my project. And it worked =) thanks!!!! you are doing a terrific job ill be waiting for the next release.

                Comment


                • #9
                  I did a snapshot build with that code in it shortly after pushing the code into GitHub...and even then there is the nightly scheduled snapshot build, so even if I hadn't there would've been a snapshot build within 24 hours of pushing it to GitHub. The version would be 1.0.0.BUILD-SNAPSHOT (and you'd need the SpringSource snapshot repository declared in your build).

                  Comment


                  • #10
                    Hi, i have same trouble. Early i used a spring-social-linkedin lib from http://mvn-adamgent.googlecode.com/svn/maven/release maven repository and had working project (this is some simplified library without getUserProfileFull method). But now i need this method and i try use spring-social-linkedin lib from http://maven.springframework.org/milestone (snapshot or release) and have exception - java.lang.NoSuchMethodError: org.codehaus.jackson.map.SerializationConfig.withS erializationInclusion(Lorg/codehaus/jackson/map/annotate/JsonSerialize$InclusionLorg/codehaus/jackson/map/SerializationConfig;

                    i tried use spring-social-linkedin 1.0.0.RC1 from milestone and spring-social-linkedin 1.0.0.BUILD-SNAPSHOT form snapshot rep and had no luck.
                    Can we help me?
                    Last edited by andreyK; Apr 9th, 2013, 06:26 AM.

                    Comment

                    Working...
                    X