Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NotSerializableException #15

Open
marcosinigaglia opened this issue Mar 19, 2013 · 9 comments
Open

NotSerializableException #15

marcosinigaglia opened this issue Mar 19, 2013 · 9 comments

Comments

@marcosinigaglia
Copy link

Hi, i try to use Memcache to store a ebean model object.
I save the object but i have this exception:
"java.io.NotSerializableException: play.libs.F$Tuple"

Any ideas? Thanks

@Enalmada
Copy link
Contributor

You can only store things that are serializable and something you are trying to store is not.
Some extra info that may be relevant: http://stackoverflow.com/questions/11600213/why-doesnt-java-lang-object-implement-the-serializable-interface

@jakoblind
Copy link

so lets say I have a case class. How do I make that serializable? When I try to cache an instance of my case class Product below I get an error.

case class Product(id: Int, title: Option[String], desc: Option[String], image: Option[String])

@mumoshu
Copy link
Contributor

mumoshu commented Apr 14, 2013

You can try java.io.Externalizable to make your own class serializable.

Here's what I have tested:

e04e1663d

@jakoblind
Copy link

Then I must implement some Java interface? I dont like that solution :)

@mumoshu
Copy link
Contributor

mumoshu commented Apr 16, 2013

Hi,

How about using MessagePack to serialize any object to bytes, then putting it in memcached?

I have read that Pinterest uses MessagePack and memcached this way :)

@yokomizor
Copy link

Unfortunately play.mvc.Results is not serializable, then caching HTTP responses does not work:

@Cached(key = "homePage")
public static Result index() {
    return ok("Hello world");
}

Stack:

java.io.NotSerializableException: play.mvc.Results$Status
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1183) ~[na:1.7.0_60]
        at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347) ~[na:1.7.0_60]
        at com.github.mumoshu.play2.memcached.MemcachedPlugin$CustomSerializing.serialize(MemcachedPlugin.scala:96) ~[play2-memcached_2.10-0.6.0.jar:0.6.0]
        at net.spy.memcached.transcoders.SerializingTranscoder.encode(SerializingTranscoder.java:162) ~[spymemcached-2.9.0.jar:2.9.0]
        at net.spy.memcached.MemcachedClient.asyncStore(MemcachedClient.java:291) ~[spymemcached-2.9.0.jar:2.9.0]

@anoopsin
Copy link

Any news on this one ?

@Enalmada
Copy link
Contributor

This link helped me as a sample: https://gist.github.com/ramn/5566596
Inlining the important parts, @serialversionuid() and extends Serializable here since links can rot...

@SerialVersionUID(15L)
class Animal(name: String, age: Int) extends Serializable {
  ...
}

@mkurz
Copy link
Member

mkurz commented Jul 19, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants