Failed to parse node with class

1,346 views
Skip to first unread message

Kazim Baygan

unread,
Mar 31, 2015, 12:32:38 PM3/31/15
to fireba...@googlegroups.com
I am getting "Failed to parse node with class" when I 'updateClidren'.

here is my code

                Prize prize = new Prize(UUID.randomUUID().toString(), "toothpaste", 10, "$2.00", createAndUpdateDate, createAndUpdateDate, "X");
Map<String, Object> prizes = new HashMap<String, Object>();
prizes.put(prize.getUniqueId(), prize);

               ref.child(FirebaseInfo.BUSINESS_PUBLIC_NODE_NAME).child("1234").child("prizes").updateChildren(prizes);
Here is what I get:

   com.firebase.client.FirebaseException: Failed to parse node with class class com.baytek.library.model.Prize
            at com.firebase.client.snapshot.NodeUtilities.NodeFromJSON(NodeUtilities.java:86)
            at com.firebase.client.snapshot.NodeUtilities.NodeFromJSON(NodeUtilities.java:13)
            at com.firebase.client.Firebase.updateChildren(Firebase.java:466)
            at com.firebase.client.Firebase.updateChildren(Firebase.java:451)
            at com.baytek.library.service.FireBaseIntentService.handleActionInsertReward(FireBaseIntentService.java:376)
            at com.baytek.library.service.FireBaseIntentService.onHandleIntent(FireBaseIntentService.java:283)
            at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:155)
            at android.os.HandlerThread.run(HandlerThread.java:61)
03-30 21:51:33.515     4224-468/? E/MediaHTTPConnection﹕ unknown exception java.lang.NullPointerException: Attempt to invoke virtual method 'java.net.URL java.net.HttpURLConnection.getURL()' on a null object reference
device not found


com.baytek.library.model.Prize is just a POJO...

Also, I verified that my path to children does exist...

Is this a bug or am I missing something?

Jonny Dimond

unread,
Mar 31, 2015, 3:33:16 PM3/31/15
to fireba...@googlegroups.com
Hi Kazim,

Thanks for sending this in.

We currently don't support POJOs with updateChildren, only with setValue. We'll discuss internally if we want to add this option in the future.
For this particular use case, you can use
child(prize.getUniqueId()).setValue(prize)
instead.

Jonny

Kazim Baygan

unread,
Mar 31, 2015, 7:01:31 PM3/31/15
to fireba...@googlegroups.com
Thanks Johnny... Appreciate the quick reply :)

I will use setValue...

K

Vinicius Silva

unread,
Aug 15, 2015, 3:14:12 PM8/15/15
to Firebase Google Group
is this still true?

Jonny Dimond

unread,
Aug 15, 2015, 4:00:40 PM8/15/15
to Firebase Google Group
Hi Vinicius,

yes, we still only support using POJOs for setValue.

Jonny

H

unread,
Mar 19, 2016, 11:17:58 AM3/19/16
to Firebase Google Group
Hey Kazim, alternatively you can add a serialize method to your POJO class (Prize.java) to serialize your objects to a Map:

public Map<String, Object> serialize() {
ObjectMapper objectMapper = new ObjectMapper();
return objectMapper.convertValue(this, Map.class);
}

and then use your same code like this: 

prizes.put(prize.getUniqueId(), prize.serialize());

You can put the serialize method in a base class that all your POJO classes extend so your code is nicer.

Vinod

unread,
May 6, 2016, 1:16:00 PM5/6/16
to Firebase Google Group
Thank you!. That worked :)
Reply all
Reply to author
Forward
0 new messages