Announcement Announcement Module
Collapse
No announcement yet.
Reply comment generates JSON error on Spring Social Facebook connection Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Reply comment generates JSON error on Spring Social Facebook connection

    A quite new feature in Facebook is the possibility to reply on comments. This can be done on pages. As there is a function:

    String reply = facebook.commentOperations().addComment(commentID, content);

    it should be trivial. Actually this works as it does reply the comment on facebook, but sadly it generates an exception in Java. The exception is when parsing JSON I guess since the comment is posted on Facebook and the exception clearly states something about JSON.

    Is this a known issue and if so doe's anyone know when the issue will be closed? Do I need to report this issue somewhere? I'm guessing that Facebook changed the structure of the response.

    Just for the record, I tried the same action with RestFB and the result is exactly the same.

    For completeness I have added the stack trace:

    org.springframework.http.converter.HttpMessageNotR eadableException: Could not read JSON: Can not instantiate value of type [map type; class java.util.LinkedHashMap, [simple type, class java.lang.Object] -> [simple type, class java.lang.Object]] from JSON String; no single-String constructor/factory method; nested exception is org.codehaus.jackson.map.JsonMappingException: Can not instantiate value of type [map type; class java.util.LinkedHashMap, [simple type, class java.lang.Object] -> [simple type, class java.lang.Object]] from JSON String; no single-String constructor/factory method
    at org.springframework.http.converter.json.MappingJac ksonHttpMessageConverter.readInternal(MappingJacks onHttpMessageConverter.java:127)
    at org.springframework.http.converter.AbstractHttpMes sageConverter.read(AbstractHttpMessageConverter.ja va:153)
    at org.springframework.web.client.HttpMessageConverte rExtractor.extractData(HttpMessageConverterExtract or.java:81)
    at org.springframework.web.client.RestTemplate.doExec ute(RestTemplate.java:446)
    at org.springframework.web.client.RestTemplate.execut e(RestTemplate.java:415)
    at org.springframework.web.client.RestTemplate.postFo rObject(RestTemplate.java:294)
    at org.springframework.social.facebook.api.impl.Faceb ookTemplate.publish(FacebookTemplate.java:203)
    at org.springframework.social.facebook.api.impl.Comme ntTemplate.addComment(CommentTemplate.java:55)
    at com.socialpainkiller.utils.test.fb.spring.Facebook .replyCommentSpring(Facebook.java:16)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknow n Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.junit.internal.runners.TestMethod.invoke(TestM ethod.java:59)
    at org.junit.internal.runners.MethodRoadie.runTestMet hod(MethodRoadie.java:98)
    at org.junit.internal.runners.MethodRoadie$2.run(Meth odRoadie.java:79)
    at org.junit.internal.runners.MethodRoadie.runBefores ThenTestThenAfters(MethodRoadie.java:87)
    at org.junit.internal.runners.MethodRoadie.runTest(Me thodRoadie.java:77)
    at org.junit.internal.runners.MethodRoadie.run(Method Roadie.java:42)
    at org.junit.internal.runners.JUnit4ClassRunner.invok eTestMethod(JUnit4ClassRunner.java:88)
    at org.junit.internal.runners.JUnit4ClassRunner.runMe thods(JUnit4ClassRunner.java:51)
    at org.junit.internal.runners.JUnit4ClassRunner$1.run (JUnit4ClassRunner.java:44)
    at org.junit.internal.runners.ClassRoadie.runUnprotec ted(ClassRoadie.java:27)
    at org.junit.internal.runners.ClassRoadie.runProtecte d(ClassRoadie.java:37)
    at org.junit.internal.runners.JUnit4ClassRunner.run(J Unit4ClassRunner.java:42)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestR eference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecutio n.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(RemoteTestRunner.java:197)
    Caused by: org.codehaus.jackson.map.JsonMappingException: Can not instantiate value of type [map type; class java.util.LinkedHashMap, [simple type, class java.lang.Object] -> [simple type, class java.lang.Object]] from JSON String; no single-String constructor/factory method
    at org.codehaus.jackson.map.deser.std.StdValueInstant iator._createFromStringFallbacks(StdValueInstantia tor.java:379)
    at org.codehaus.jackson.map.deser.std.StdValueInstant iator.createFromString(StdValueInstantiator.java:2 68)
    at org.codehaus.jackson.map.deser.std.MapDeserializer .deserialize(MapDeserializer.java:244)
    at org.codehaus.jackson.map.deser.std.MapDeserializer .deserialize(MapDeserializer.java:33)
    at org.codehaus.jackson.map.ObjectMapper._readMapAndC lose(ObjectMapper.java:2732)
    at org.codehaus.jackson.map.ObjectMapper.readValue(Ob jectMapper.java:1923)
    at org.springframework.http.converter.json.MappingJac ksonHttpMessageConverter.readInternal(MappingJacks onHttpMessageConverter.java:124)
    ... 30 more

  • #2
    Which version of Spring Social Facebook are you using? 1.1.0.M3? 1.0.3? If the answer is either of these two, then my immediate (yet educated) guess is that your application has Jackson 1.9.x in the classpath, but you need Jackson 2 (such as v2.2.2).

    I can tell that Jackson 1.9.x is in the classpath because it references org.codehaus.jackson.* types, but Jackson 2 uses com.fasterxml.jackson as its base package.

    Comment


    • #3
      First of all, I'm using 1.0.3 and of course I should have told that, sorry.

      Second of all, you are absolutely right, adding Jackson 2 resolves the problem. This is closed for me, thanks habuma!

      Tim

      Comment


      • #4
        Glad to hear it works now!

        Comment


        • #5
          No its not Quite interestingly the problem persists with the Jackson 2 and higher versions

          org.springframework.http.converter.HttpMessageNotR eadableException: Could not read JSON: Can not instantiate value of type [map type; class java.util.LinkedHashMap, [simple type, class java.lang.Object] -> [simple type, class java.lang.Object]] from String value; no single-String constructor/factory method; nested exception is com.fasterxml.jackson.databind.JsonMappingExceptio n: Can not instantiate value of type [map type; class java.util.LinkedHashMap, [simple type, class java.lang.Object] -> [simple type, class java.lang.Object]] from String value; no single-String constructor/factory method
          at org.springframework.http.converter.json.MappingJac kson2HttpMessageConverter.readJavaType(MappingJack son2HttpMessageConverter.java:171)
          at org.springframework.http.converter.json.MappingJac kson2HttpMessageConverter.read(MappingJackson2Http MessageConverter.java:163)
          at org.springframework.web.client.HttpMessageConverte rExtractor.extractData(HttpMessageConverterExtract or.java:94)
          at org.springframework.web.client.RestTemplate.doExec ute(RestTemplate.java:491)
          at org.springframework.web.client.RestTemplate.execut e(RestTemplate.java:460)
          at org.springframework.web.client.RestTemplate.postFo rObject(RestTemplate.java:309)
          at org.springframework.social.facebook.api.impl.Faceb ookTemplate.publish(FacebookTemplate.java:266)
          at org.springframework.social.facebook.api.impl.Comme ntTemplate.addComment(CommentTemplate.java:58)
          at com.pennant.social.Facebook.sendPosts(Facebook.jav a:611)
          at com.pennant.batch.job.PostFeedsJobScheduler.execut eInternal(PostFeedsJobScheduler.java:147)
          at com.pennant.webui.applicationmaster.socialprofile. TwitterFeedsCtrl.onClick$btnPostfeeds(TwitterFeeds Ctrl.java:283)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(Unknow n Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
          at java.lang.reflect.Method.invoke(Unknown Source)
          at org.zkoss.zk.ui.event.GenericEventListener.onEvent (GenericEventListener.java:88)
          at com.pennant.webui.util.GFCBaseCtrl.onEvent(GFCBase Ctrl.java:172)
          at org.zkoss.zk.ui.AbstractComponent.onEvent(Abstract Component.java:2742)
          at org.zkoss.zk.ui.AbstractComponent.service(Abstract Component.java:2713)
          at org.zkoss.zk.ui.AbstractComponent.service(Abstract Component.java:2654)
          at org.zkoss.zk.ui.impl.EventProcessor.process(EventP rocessor.java:136)
          at org.zkoss.zk.ui.impl.EventProcessingThreadImpl.pro cess0(EventProcessingThreadImpl.java:534)
          at org.zkoss.zk.ui.impl.EventProcessingThreadImpl.sen dEvent(EventProcessingThreadImpl.java:126)
          at org.zkoss.zk.ui.event.Events.sendEvent(Events.java :334)
          at org.zkoss.zk.ui.event.Events.sendEvent(Events.java :344)
          at org.zkoss.zk.ui.AbstractComponent$ForwardListener. onEvent(AbstractComponent.java:3180)
          at org.zkoss.zk.ui.AbstractComponent.onEvent(Abstract Component.java:2742)
          at org.zkoss.zk.ui.AbstractComponent.service(Abstract Component.java:2713)
          at org.zkoss.zk.ui.AbstractComponent.service(Abstract Component.java:2654)
          at org.zkoss.zk.ui.impl.EventProcessor.process(EventP rocessor.java:136)
          at org.zkoss.zk.ui.impl.EventProcessingThreadImpl.pro cess0(EventProcessingThreadImpl.java:534)
          at org.zkoss.zk.ui.impl.EventProcessingThreadImpl.run (EventProcessingThreadImpl.java:461)
          Caused by: com.fasterxml.jackson.databind.JsonMappingExceptio n: Can not instantiate value of type [map type; class java.util.LinkedHashMap, [simple type, class java.lang.Object] -> [simple type, class java.lang.Object]] from String value; no single-String constructor/factory method
          at com.fasterxml.jackson.databind.deser.std.StdValueI nstantiator._createFromStringFallbacks(StdValueIns tantiator.java:428)
          at com.fasterxml.jackson.databind.deser.std.StdValueI nstantiator.createFromString(StdValueInstantiator. java:299)
          at com.fasterxml.jackson.databind.deser.std.MapDeseri alizer.deserialize(MapDeserializer.java:306)
          at com.fasterxml.jackson.databind.deser.std.MapDeseri alizer.deserialize(MapDeserializer.java:26)
          at com.fasterxml.jackson.databind.ObjectMapper._readM apAndClose(ObjectMapper.java:2993)
          at com.fasterxml.jackson.databind.ObjectMapper.readVa lue(ObjectMapper.java:2158)
          at org.springframework.http.converter.json.MappingJac kson2HttpMessageConverter.readJavaType(MappingJack son2HttpMessageConverter.java:168)
          ... 31 more





          please revert me with the solution

          thanks
          madhu



          Comment

          Working...
          X