while playing with wicket and akka (and cassandra), I noticed that the serialization doc is somewhat out of date.
the docs (http://doc.akkasource.org/serialization) tell me that:
------------------------------------------------------------------------
If you are sending messages to a remote Actor/Active Object and these messages are implementing one of the predefined interfaces/traits in the 'se.scalablesolutions.akka.serialization.Serialization.*' object, then Akka will transparently detect which serialization format it should use as wire protocol and will automatically serialize and deserialize the message according to this protocol.
Each serialization interface/trait in
* se.scalablesolutions.akka.serialization.Serialization.*
has a matching serializer in
* se.scalablesolutions.akka.serialization.Serializer.*.
------------------------------------------------------------------------
But It seems that se.scalablesolutions.akka.serialization.Serialization.* is no more...
------------------------------------------------------------------------
scala> import se.scalablesolutions.akka.serialization.Serialization._
<console>:4: error: value Serialization is not a member of package se.scalablesolutions.akka.serialization
import se.scalablesolutions.akka.serialization.Serialization._
^
scala> import se.scalablesolutions.akka.serialization.Serializer
import se.scalablesolutions.akka.serialization.Serializer
----------------------------------------------------------------------
Furthermore the example for JSON: Scala does not work:
-----------
scala> import se.scalablesolutions.akka.serialization.Serializable.ScalaJSON
import se.scalablesolutions.akka.serialization.Serializable.ScalaJSON
scala> case class MyMessage(val id: String, val value: Tuple2[String, Int]) extends ScalaJSON
defined class MyMessage
scala> val message = MyMessage("id", ("hello", 34))
message: MyMessage = MyMessage(id,(hello,34))
scala> val json = message.toJSON
java.lang.UnsupportedOperationException: Class class MyMessage not supported for conversion
at sjson.json.JsBean$class.toJSON(JsBean.scala:193)
at sjson.json.Serializer$SJSON$.toJSON(Serializer.scala:107)
at sjson.json.Serializer$SJSON$class.out(Serializer.scala:37)
at sjson.json.Serializer$SJSON$.out(Serializer.scala:107)
at se.scalablesolutions.akka.serialization.Serializable$S...
scala>
----------------
I can fix this by adding the @BeanInfo annotation.
but the deserialization in the second example yields this:
-----------------------------------------------
scala> @BeanInfo case class Foo()
defined class Foo
scala> val foo = new Foo()
foo: Foo = Foo()
scala> val json = Serializer.ScalaJSON.out(foo)
java.lang.UnsupportedOperationException: Class class Foo not supported for conversion
at sjson.json.JsBean$class.toJSON(JsBean.scala:193)
at sjson.json.Serializer$SJSON$.toJSON(Serializer.scala:107)
at sjson.json.Serializer$SJSON$class.out(Serializer.scala:37)
at sjson.json.Serializer$SJSON$.out(Serializer.scala:107)
at se.scalablesolutions.akka.serialization.Serializer$ScalaJSON...
-----------------------
ok, it seems the case class needs at least one attribute:
------------------------
scala> @BeanInfo case class Foo(name: String)
defined class Foo
scala> val foo = new Foo("foo")
foo: Foo = Foo(foo)
scala> val json = Serializer.ScalaJSON.out(foo)
json: Array[Byte] = Array(123, 34, 110, 97, 109, 101, 34, 58, 34, 102, 111, 111, 34, 125)
scala> val fooCopy = Serializer.ScalaJSON.in(json).asInstanceOf[Foo]
<console>:10: error: type mismatch;
found : Array[Byte]
required: String
val fooCopy = Serializer.ScalaJSON.in(json).asInstanceOf[Foo]
^
---------------------------
ok, so I give it a string.
But then...
--------------------------
scala> val fooCopy = Serializer.ScalaJSON.in(new String(json)).asInstanceOf[Foo]
java.lang.ClassCastException: dispatch.json.JsObject cannot be cast to Foo
at .<init>(<console>:10)
at .<clinit>(<console>)
at RequestResult$.<init>(<console>:3)
at RequestResult$.<clinit>(<console>)
at RequestResult$result(<console>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
...
scala>
-------------------------
Now, I could fix the sample code (in a way), but I don't know enough to fix the bit about the missing Serialization class.
- Eckart
--
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/akka-user?hl=en.
--
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/akka-user?hl=en.
That was the current trunk version. So, alas, the problem does not go away ...
Anyhow, I can see the problem in the source..
1. the Serialization class does not exist
2. sjson.json.Serializer.in does have a type parameter that returns a properly constructed Foo,
but se.scalablesolutions.akka.serialization.Serializer.ScalaJSON does not.
Otherwise its just minor inconsistencies in the documentation.
> > akka-user+...@googlegroups.com<akka-user%2Bunsu...@googlegroups.com>
no problem.
I can fix the sample code myself, if you like...
> > akka-user+...@googlegroups.com<akka-user%2Bunsu...@googlegroups.com>
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
----
Jonas Bonér
twitter: @jboner
blog: http://jonasboner.com
work: http://scalablesolutions.se
code: http://github.com/jboner
code: http://akkasource.org
also: http://letitcrash.com
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
Yep.
Just now.
> > Debasish Ghosh
> > http://manning.com/ghosh
> >
> > Twttr: @debasishg
> > Blog: http://debasishg.blogspot.com
> > Code: http://github.com/debasishg
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Akka User List" group.
> > To post to this group, send email to akka...@googlegroups.com.
> > To unsubscribe from this group, send email to
sounds good. I am looking forward to it.
Eckart
my pleasure
:-)
> > <akka-user%2Bunsu...@googlegroups.com<akka-user%252Buns...@googlegroups.com>
> > >
> > > >>>>> <akka-user%2Bunsu...@googlegroups.com<akka-user%252Buns...@googlegroups.com>
> > >
> > > >>>>> .
> > > >>>>> For more options, visit this group at
> > > >>>>> http://groups.google.com/group/akka-user?hl=en.
> > > >>>>>
> > > >>>>>
> > > >>>>>
> > > >>>>
> > > >>>>
> > > >>>>
> > > >>> --
> > > >>> You received this message because you are subscribed to the Google
> > Groups
> > > >>> "Akka User List" group.
> > > >>> To post to this group, send email to akka...@googlegroups.com.
> > > >>> To unsubscribe from this group, send email to
> > > >>> akka-user+...@googlegroups.com<akka-user%2Bunsu...@googlegroups.com>
> > <akka-user%2Bunsu...@googlegroups.com<akka-user%252Buns...@googlegroups.com>
> > >
> > > >>> .
> > > >>> For more options, visit this group at
> > > >>> http://groups.google.com/group/akka-user?hl=en.
> > > >>>
> > > >>>
> > > >> --
> > > >> You received this message because you are subscribed to the Google
> > Groups
> > > >> "Akka User List" group.
> > > >> To post to this group, send email to akka...@googlegroups.com.
> > > >> To unsubscribe from this group, send email to
> > > >> akka-user+...@googlegroups.com<akka-user%2Bunsu...@googlegroups.com>
> > <akka-user%2Bunsu...@googlegroups.com<akka-user%252Buns...@googlegroups.com>
> > >
> > > >> .
> > > >> For more options, visit this group at
> > > >> http://groups.google.com/group/akka-user?hl=en.
> > > >>
> > > >>
> > > >
> > > >
> > > > --
> > > > Debasish Ghosh
> > > > http://manning.com/ghosh
> > > >
> > > > Twttr: @debasishg
> > > > Blog: http://debasishg.blogspot.com
> > > > Code: http://github.com/debasishg
> > > >
> > > > --
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "Akka User List" group.
> > > > To post to this group, send email to akka...@googlegroups.com.
> > > > To unsubscribe from this group, send email to
> > > > akka-user+...@googlegroups.com<akka-user%2Bunsu...@googlegroups.com>
> > <akka-user%2Bunsu...@googlegroups.com<akka-user%252Buns...@googlegroups.com>