Error with Marshal.dump/load

Hello,

I am trying to write a custom Activesupport:Cache store which uses
Marshal.load/dump to load/dump data into the cache store. When using an
external java application memory store and doing a “put” i get the
following
error

java.io.WriteAbortedException: writing aborted;
java.io.NotSerializableException: org.jcodings.specific.ASCIIEncoding
at
java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1309)
at
java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1910)
at
java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1834)
at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1719)
at
java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
at
java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1910)
at
java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1834)
at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1719)
at
java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
at
java.io.ObjectInputStream.readArray(ObjectInputStream.java:1634)
at
java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
at
java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1910)
at
java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1834)
at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1719)
at
java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
at
java.io.ObjectInputStream.readObject(ObjectInputStream.java:348)

Full stack trace here http://pastie.org/1030700

Any ideas?

Thanks
AD

So i see the issue, it appears there is an issue with serializing when
the
value is a ruby class, is there a proper way around this ?

Make sure you’re taking the marshalling bytes and then convert them to
a Java byte array with String#to_java_bytes. Then stuff that in your
Java cache store. On the way back in, Use
String.from_java_bytes(bytearray) to re-create the Ruby String, then
Marshal.load from that.

/Nick

On Sun, Jul 4, 2010 at 11:03 PM, AD [email protected] wrote:

Marshal.load/dump to load/dump data into the cache store. When using an
java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1834)
at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1719)
at
java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
at
java.io.ObjectInputStream.readObject(ObjectInputStream.java:348)

Full stack trace here http://pastie.org/1030700
Any ideas?
Thanks
AD


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

The problem is activesupport::cache is just passing a class object with
an
instance variable that is marshalled (I misread the original code).
Things
seem to choke when i try to serialize a class object not a marshalled
object.

Is there a safe way to serialize a ruby class instance ?

Sorry, I’m not quite getting the particulars of AS::Cache at this
moment. Can you show us an example? If you can post a failing test
case into JIRA, I’d be happy to take a look.

/Nick

On Wed, Jul 7, 2010 at 8:43 PM, AD [email protected] wrote:

Java cache store. On the way back in, Use

error
at

    at

Any ideas?


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email