pojo's that you want to send over the bus need to follow these constraints:
a) have @ExposedEntity annotation
b) follow the java bean conventions (no arg ctor, getter and setter)
c) implement java.io.Serializable
From the example you've shown I can only confirm c).
/Heiko
On Mar 3, 2010, at 4:47 PM, Alejandro Montenegro wrote:
Hi guys,
I'm trying to send an array of objects from server to client:
StockPrice[] prices = getPrices(symbols);
MessageBuilder.createMessage()
.toSubject("BroadcastReceiver")
.signalling().with("data", prices)
.noErrorHandling()
.sendNowWith(bus); (1)
where StockPrice is:
public class StockPrice implements Serializable{
private String symbol;
private double price;
private double change;
...
but when executing (1) I get the following error:
[ERROR]Exception in thread "Timer-2" java.lang.RuntimeException: cannot
serialize type: com.ifitec.gwt.client.StockPrice
[ERROR] at org.jboss.errai.bus.server.io.JSONEncoder._encode(JSONEncoder.java:59)
[ERROR] at
org.jboss.errai.bus.server.io.JSONEncoder.encodeArray(JSONEncoder.java:147)
[ERROR] at org.jboss.errai.bus.server.io.JSONEncoder._encode(JSONEncoder.java:55)
[ERROR] at org.jboss.errai.bus.server.io.JSONEncoder.encode(JSONEncoder.java:38)
[ERROR] at
org.jboss.errai.bus.server.io.JSONMessageServer._addObjectPart(JSONMessageServer.java:13)
[ERROR] at
org.jboss.errai.bus.client.api.base.JSONMessage.set(JSONMessage.java:191)
[ERROR] at
org.jboss.errai.bus.client.api.builder.AbstractMessageBuilder$2.with(AbstractMessageBuilder.java:60)
So looking at JSONEncoder I discovered the serializableTypes variable which is used to
check if objects are serializable:
else if (serializableTypes.contains(v.getClass()) || tHandlers.containsKey(v.getClass()))
{
return encodeObject(v);
So now Im looking for how to put in serializableTypes the StockPrice class that I have
created.
Please let me know if Im correct that I have to fill serializableTypes or maybe Im
totally wrong. And if any can let me know how to fill it would be great.
thanks
Alejandro
(amontenegro)
_______________________________________________
errai-users mailing list
errai-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/errai-users