GWT RPC Serialization Error

334 views
Skip to first unread message

Abhishek Yadav

unread,
Jul 22, 2022, 9:43:24 AM7/22/22
to GWT Users
I am using GWT 2.9 and I am getting below error

SEVERE: Exception while dispatching incoming RPC call
com.google.gwt.user.client.rpc.SerializationException: Type 'com.xyz.nos.model.NosOptionModel' 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 = com.xyz.nos.model.NosOptionModel@6cad8f33

SEVERE: Exception while dispatching incoming RPC call
com.google.gwt.user.client.rpc.SerializationException: Type 'com.xyz.nos.model.NosOptionModel' 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 = com.xyz.nos.model.NosOptionModel@5fc5e111

SEVERE: Exception while dispatching incoming RPC call
com.google.gwt.user.client.rpc.SerializationException: Type 'com.xyz.nos.model.NosCaseDetailModel' 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 = com.xyz.nos.model.NosCaseDetailModel@af3642f

SEVERE: Exception while dispatching incoming RPC call
com.google.gwt.user.client.rpc.SerializationException: Type 'com.xyz.nos.model.CountryGroupModel' 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 = com.xyz.nos.model.CountryGroupModel@51987007

SEVERE: Exception while dispatching incoming RPC call
com.google.gwt.user.client.rpc.SerializationException: Type 'com.xyz.nos.model.NosUser' 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 = com.xyz.nos.model.NosUser@28bbfa7f

I am doing GWT RPC for populating liststore of combobox and getting above exception while performing it from EntryPoint class. All the above classes are Pojo's and all the fields of these classes are Serializable

I have tried all possible solutions given in java - GWT - RPC SerializationException - Stack Overflow

I have defined my service as below 
public interface INamedComboListDataProvider<M> extends RemoteService {
    public List<M> load(String name);
}

I also have checked my serializationWhitelist and it only contain following 25 classes
{class com.google.gwt.user.client.ui.TreeListenerCollection=true, class java.lang.String=true, class com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException=true, class com.google.gwt.user.client.ui.FocusListenerCollection=true, class com.google.gwt.user.client.rpc.RpcTokenException=true, class java.util.LinkedList=true, class java.lang.RuntimeException=false, class com.google.gwt.user.client.ui.LoadListenerCollection=true, class com.google.gwt.user.client.ui.ClickListenerCollection=true, class com.google.gwt.user.client.ui.FormHandlerCollection=true, class java.lang.Throwable=false, class com.google.gwt.user.client.ui.KeyboardListenerCollection=true, class com.google.gwt.user.client.ui.MouseListenerCollection=true, class com.google.gwt.user.client.ui.TabListenerCollection=true, class java.util.Vector=true, class com.google.gwt.user.client.ui.ChangeListenerCollection=true, class com.google.gwt.user.client.ui.ScrollListenerCollection=true, class com.google.gwt.user.client.ui.PopupListenerCollection=true, class com.google.gwt.user.client.ui.MouseWheelListenerCollection=true, class java.util.Arrays$ArrayList=true, class java.lang.Exception=false, class java.util.ArrayList=true, class java.util.Collections$EmptyList=true, class java.util.Collections$SingletonList=true, class com.google.gwt.user.client.ui.TableListenerCollection=true}

I also have added project folder structure in attachment.
Can anybody guide me where I am going wrong and why does the serializationwhilteList does not contain the pojo models ?


GWT RPC Serialization.jpg

Jens

unread,
Jul 22, 2022, 5:23:30 PM7/22/22
to GWT Users
Your interface has a type parameter with no upper bound so it is effectively Object. Thus GWT does not know which classes to scan because it will not scan every subclass of Object. Either give your type parameter an upper bound using a common interface or create a dummy method in your service interface that returns a dummy class which references all your classes you want to use in your load method. 

Abhishek Yadav

unread,
Jul 25, 2022, 11:17:56 AM7/25/22
to GWT Users
Thanks Jens for pointing out the issue. It is working now.
Reply all
Reply to author
Forward
0 new messages