ClassCastException: org.codehaus.jackson.node.NullNode cannot be cast to org.codehaus.jackson.node.TextNode when calling Facebook API

422 views
Skip to first unread message

uri

unread,
Aug 26, 2012, 8:26:20 AM8/26/12
to bat...@googlegroups.com
Hi all,
I'm getting a new error since Friday when calling Facebook Ads API and I was wondering how can I determine if thats a bug on Facebook end and mine? Or batchFB issue?

I'm using batchFB 2.1 r138. 

The exception is:

java.lang.ClassCastException: org.codehaus.jackson.node.NullNode cannot be cast to org.codehaus.jackson.node.TextNode
        at com.googlecode.batchfb.impl.GraphNodeExtractor.convert(GraphNodeExtractor.java:72)
        at com.googlecode.batchfb.impl.GraphNodeExtractor.convert(GraphNodeExtractor.java:39)

Its happens (for example) when trying to update a bid - I get the following:
{"code":397,"headers":[{"name":"Connection","value":"close"},{"name":"Content-Type","value":"text/html; charset=utf-8"}],"body":null}
and on that I get the ClassCastException at com.googlecode.batchfb.impl.GraphNodeExtractor#convert where the instruction is: TextNode body = (TextNode) batchPart.get("body");

The expected behavior is go get something like the following:
{"code":200,"headers":[{"name":"Access-Control-Allow-Origin","value":"*"},{"name":"Cache-Control","value":"private, no-cache, no-store, must-revalidate"},{"name":"Connection","value":"close"},{"name":"Content-Type","value":"text/javascript; charset=UTF-8"},{"name":"Expires","value":"Sat, 01 Jan 2000 00:00:00 GMT"},{"name":"Pragma","value":"no-cache"}],"body":"true"}

--> the difference is at the end of the reply, "true" or "false" but not "budy":null.

Thank you,
Uri

Jeff Schnitzer

unread,
Aug 26, 2012, 4:48:40 PM8/26/12
to bat...@googlegroups.com
This is very odd and not what I expect from Jackson's JsonNode.get().
I will ask about this on the Jackson list.

Jeff

Jeff Schnitzer

unread,
Aug 26, 2012, 5:21:34 PM8/26/12
to bat...@googlegroups.com
FWIW I've fixed batchfb trunk to work with the current Jackson behavior.

Jeff

uri

unread,
Aug 27, 2012, 3:50:30 AM8/27/12
to bat...@googlegroups.com, je...@infohazard.org
Hi Jeff,
What is the expected Jackson behavior on this? If I do JsonNode.get("body")  on an object that looks like {"body":null} then I do expect to get a NullNode isnt it?

Jeff Schnitzer

unread,
Aug 28, 2012, 9:39:54 PM8/28/12
to bat...@googlegroups.com
According to Tatu, this is by design. JsonNode.get() will return a
NullNode if there is an explicit null. So basically null checks need
to be "if (subnode == null || subnode.isNull())"

Jeff
Reply all
Reply to author
Forward
0 new messages