JRuby Hash serialization issue

Hi ,

I am trying Storm ( https://github.com/nathanmarz/storm ) using RedStorm
(
https://github.com/colinsurprenant/redstorm ). The data passed between
tasks need to be serializable but I got exception when passing JRuby
Hashes
around. The error message is like the following:

1461 [Thread-49] ERROR backtype.storm.util - Async loop died!
java.io.NotSerializableException: org.jruby.RubyHash$RubyHashEntry
at
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1164)
at
java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1518)
at
java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1483)
at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1400)
at
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158)
at
java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:330)
at
backtype.storm.serialization.JavaSerialization.serialize(JavaSerialization.java:20)
at
backtype.storm.serialization.JavaSerialization.serialize(JavaSerialization.java:14)
at
backtype.storm.serialization.FieldSerialization.serialize(FieldSerialization.java:26)
at
backtype.storm.serialization.ValuesSerializer.serializeInto(ValuesSerializer.java:50)
at
backtype.storm.serialization.TupleSerializer.serialize(TupleSerializer.java:31)
at
backtype.storm.daemon.worker$fn__3076$exec_fn__860__auto____3077$fn__3137$fn__3138.invoke(worker.clj:189)
at
backtype.storm.daemon.worker$fn__3076$exec_fn__860__auto____3077$fn__3137.invoke(worker.clj:184)
at clojure.lang.AFn.applyToHelper(AFn.java:165)
at clojure.lang.AFn.applyTo(AFn.java:151)
at clojure.core$apply.invoke(core.clj:540)
at backtype.storm.util$async_loop$fn__445.invoke(util.clj:215)
at clojure.lang.AFn.run(AFn.java:24)
at java.lang.Thread.run(Thread.java:680)

I also posted this in RedStorm issue tracker (
https://github.com/colinsurprenant/redstorm/issues/8 ). Can any one have
experience work with JRuby & Java serialization give some more
suggestions
?

Thanks
Best Regards,
Stone

Why RubyHashEntry doesn’t implement java.io.Serializable but RubyHash
does
?

http://www.jruby.org/apidocs/org/jruby/RubyHash.html
http://www.jruby.org/apidocs/org/jruby/RubyHash.RubyHashEntry.html

Best Regards,
Stone

Hello,

On Fri, Dec 16, 2011 at 12:24 AM, Stone [email protected] wrote:

I am trying Storm ( https://github.com/nathanmarz/storm ) using RedStorm (
https://github.com/colinsurprenant/redstorm ). The data passed between tasks
need to be serializable but I got exception when passing JRuby Hashes
around. The error message is like the following:

This might be just a workaround, and I’m not sure it really work for
you.

You can use Java’s Map type instead of RubyHash. For example,
java.util.HashMap, java.util.concurrentHashMap etc are all
serializable. Except a few methods, Java’s Map type object works like
RubyHash.

-Yoko

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs