Add class to SerializationPolicy whitelist...

424 views
Skip to first unread message

Edgenius

unread,
Nov 15, 2009, 10:51:09 PM11/15/09
to Google Web Toolkit
It is not new questions in this group. But I face a new problem in
2.0M2 as SerializationPolicy logic is changed. I know GWT will put
serializition class into SerializationPolicy whitelist. Before 2.0, I
create a dummy method which hold all classes I want to pass to client
side but they are not inside any method's parameters or exceptions.
It looks:

public interface RemoteServiceAsync {
public void serialPolicy(ClientAuthenticationException
ae,ClientAccessDeniedException ade, CaptchaVerifiedException ce
TextModel textModel,LinkModel linkModel, MessageListModel mlm,
AsyncCallback<Object> callback);
}

These Exception classes are a kind of "runtime exception" - For
example, ClientAuthenticationException is thrown when login failed.
It won't be checked exception as almost all methods have the
possibilty to throw this exception. It is bad to write on every method
like "int myMethod() throws ClientAuthenticationException.

I guess 2.0 becomes smarter - it can distinguish the unused method and
kick out my runtime exceptions classes from SerializationPolicy
whitelist. Unfortunately, it brings troubles as well. So, do we have
an easy to way to expand whitelist?

Oleg K.

unread,
Nov 21, 2009, 5:38:46 PM11/21/09
to Google Web Toolkit
I am faced the same problem.
So what is the way to customize serialization whitelist ?

felix

unread,
Nov 22, 2009, 5:17:32 AM11/22/09
to Google Web Toolkit
Hi,

i had the same troubles in my project once i moved from 1.5.2 to
2.0m2. I found the following solution:

1. create a class on the client code:

public class SerializableWhiteList implements IsSerializable {
@SuppressWarnings("unused")
private MyBean myBean;
@SuppressWarnings("unused")
private MySecondBean mySecondBean;
// Put here all Beans wich need this special treatment
}

2. Create a Method in your Service and ServiceAsync and ServiceImpl:

public interface MyService extends RemoteService {
public SerializableWhiteList serializableWhiteList
(SerializableWhiteList s);
}
public interface MyServiceAsync {
public void serializableWhiteList(SerializableWhiteList s,
AsyncCallback<SerializableWhiteList> cb);
}
public class MyServiceImpl extends RemoteServiceServlet implements
MyService {
@Override
public SerializableWhiteList serializableWhiteList
(SerializableWhiteList s) {
throw new RuntimeException("This Method is only used to put Beans to
the SerializationPolicy, please do not call it");
}
}

Greetings

wytten

unread,
Jan 15, 2010, 8:37:56 AM1/15/10
to Google Web Toolkit
I am also having serialization issues after upgrading from 1.5.3 to
2.0.0

We use BigDecimal thanks to gwt-math 2.1. We do not use BigInteger,
however after upgrading to GWT 2.0.0 our app is broken because
BigInteger is not on the whitelist. If I force it onto the whitelist
using the technique described here, the problem changes to:

com.google.gwt.user.client.rpc.SerializationException: Type '[I' was
not included in the set of types which can be serialized by this
SerializationPolicy or its Class object could not be loaded. For
security purposes, this type will not be serialized.: instance =
[I@723358

Any idea where I should look next?

Thanks.

> > serializition class into SerializationPolicywhitelist. Before 2.0, I

wytten

unread,
Jan 25, 2010, 7:08:11 AM1/25/10
to Google Web Toolkit
This has been traced to "Issue 4460: RPC fails to locate custom field
serializers in some application servers"
http://code.google.com/p/google-web-toolkit/issues/detail?id=4460
Reply all
Reply to author
Forward
0 new messages