PDA

View Full Version : BigDecimal Serialization problems



ssenecal
24 Jan 2010, 9:29 PM
I am trying to serialize a BigDecimal in my TreeModel, but I end up getting a serialization exception on the client side. I have followed the advice found in previous threads (http://www.extjs.com/forum/showthread.php?p=407598) to add an unused BigDecimal to the ModelData implementation, but I still get the exception. My class looks like



public class OrderTreeModel extends BaseTreeModel {
@SuppressWarnings("unused")
private BigDecimal bigDec; // hack so that BigDecimal is included in the GWT Serialization

@SuppressWarnings("unused")
private BigInteger bigInt; // ditto

...
}


The exception I am getting is:


[ERROR] AyncCallbackBase::onFailure
com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException:
The response could not be deserialized
at Unknown.com_google_gwt_user_client_rpc_IncompatibleRemoteServiceException_$IncompatibleRemoteServiceException__Lcom_google_gwt_user_client_rpc_IncompatibleRemoteServiceException_2Ljava_lang_String_2Ljava_lang_Throwable_2Lcom_google_gwt_user_client_rpc_IncompatibleRemoteServiceException_2(Unknown source:0)
at Unknown.com_google_gwt_user_client_rpc_impl_RequestCallbackAdapter_onResponseReceived__Lcom_google_gwt_http_client_Request_2Lcom_google_gwt_http_client_Response_2V(Unknown source:0)
at Unknown.com_google_gwt_http_client_Request_$fireOnResponseReceived__Lcom_google_gwt_http_client_Request_2Lcom_google_gwt_http_client_RequestCallback_2V(Unknown source:0)
at Unknown.com_google_gwt_http_client_RequestBuilder$1_onReadyStateChange__Lcom_google_gwt_xhr_client_XMLHttpRequest_2V(Unknown source:0)
at Unknown.anonymous(Unknown source:0)
at Unknown.com_google_gwt_core_client_impl_Impl_entry0__Ljava_lang_Object_2Ljava_lang_Object_2Ljava_lang_Object_2Ljava_lang_Object_2(Unknown source:0)
at Unknown.anonymous(Unknown source:0)
at Unknown.handleEvent(Unknown source:0)
at Unknown.anonymous(Unknown source:0)
Caused by: com.google.gwt.user.client.rpc.SerializationException:
java.math.BigDecimal/1680160536
at Unknown.com_google_gwt_user_client_rpc_SerializationException_$SerializationException__Lcom_google_gwt_user_client_rpc_SerializationException_2Ljava_lang_String_2Lcom_google_gwt_user_client_rpc_SerializationException_2(Unknown source:0)
at Unknown.com_google_gwt_user_client_rpc_impl_SerializerBase_$check__Lcom_google_gwt_user_client_rpc_impl_SerializerBase_2Ljava_lang_String_2IV(Unknown source:0)
at Unknown.com_google_gwt_user_client_rpc_impl_SerializerBase_$instantiate__Lcom_google_gwt_user_client_rpc_impl_SerializerBase_2Lcom_google_gwt_user_client_rpc_SerializationStreamReader_2Ljava_lang_String_2Ljava_lang_Object_2(Unknown source:0)
at Unknown.com_google_gwt_user_client_rpc_impl_AbstractSerializationStreamReader_$readObject__Lcom_google_gwt_user_client_rpc_impl_AbstractSerializationStreamReader_2Ljava_lang_Object_2(Unknown source:0)
at Unknown.com_extjs_gxt_ui_client_data_RpcMap_1CustomFieldSerializer_deserialize__Lcom_google_gwt_user_client_rpc_SerializationStreamReader_2Lcom_extjs_gxt_ui_client_data_RpcMap_2V(Unknown source:0)
at Unknown.com_google_gwt_user_client_rpc_impl_SerializerBase$MethodMap_$deserialize__Lcom_google_gwt_user_client_rpc_impl_SerializerBase$MethodMap_2Lcom_google_gwt_user_client_rpc_SerializationStreamReader_2Ljava_lang_Object_2Ljava_lang_String_2V(Unknown source:0)
at Unknown.com_google_gwt_user_client_rpc_impl_SerializerBase_$deserialize__Lcom_google_gwt_user_client_rpc_impl_SerializerBase_2Lcom_google_gwt_user_client_rpc_SerializationStreamReader_2Ljava_lang_Object_2Ljava_lang_String_2V(Unknown source:0)
at Unknown.com_google_gwt_user_client_rpc_impl_AbstractSerializationStreamReader_$readObject__Lcom_google_gwt_user_client_rpc_impl_AbstractSerializationStreamReader_2Ljava_lang_Object_2(Unknown source:0)
at Unknown.com_tradingscreen_supportplugins_client_rpc_dto_OrderTreeModel_1FieldSerializer_deserialize__Lcom_google_gwt_user_client_rpc_SerializationStreamReader_2Lcom_tradingscreen_supportplugins_client_rpc_dto_OrderTreeModel_2V(Unknown source:0)
at Unknown.com_google_gwt_user_client_rpc_impl_SerializerBase$MethodMap_$deserialize__Lcom_google_gwt_user_client_rpc_impl_SerializerBase$MethodMap_2Lcom_google_gwt_user_client_rpc_SerializationStreamReader_2Ljava_lang_Object_2Ljava_lang_String_2V(Unknown source:0)
at Unknown.com_google_gwt_user_client_rpc_impl_SerializerBase_$deserialize__Lcom_google_gwt_user_client_rpc_impl_SerializerBase_2Lcom_google_gwt_user_client_rpc_SerializationStreamReader_2Ljava_lang_Object_2Ljava_lang_String_2V(Unknown source:0)
at Unknown.com_google_gwt_user_client_rpc_impl_AbstractSerializationStreamReader_$readObject__Lcom_google_gwt_user_client_rpc_impl_AbstractSerializationStreamReader_2Ljava_lang_Object_2(Unknown source:0)
at Unknown.com_google_gwt_user_client_rpc_core_java_util_Collection_1CustomFieldSerializerBase_deserialize__Lcom_google_gwt_user_client_rpc_SerializationStreamReader_2Ljava_util_Collection_2V(Unknown source:0)
at Unknown.com_google_gwt_user_client_rpc_core_java_util_ArrayList_1CustomFieldSerializer_deserialize__Lcom_google_gwt_user_client_rpc_SerializationStreamReader_2Ljava_util_ArrayList_2V(Unknown source:0)
at Unknown.com_google_gwt_user_client_rpc_impl_SerializerBase$MethodMap_$deserialize__Lcom_google_gwt_user_client_rpc_impl_SerializerBase$MethodMap_2Lcom_google_gwt_user_client_rpc_SerializationStreamReader_2Ljava_lang_Object_2Ljava_lang_String_2V(Unknown source:0)
at Unknown.com_google_gwt_user_client_rpc_impl_SerializerBase_$deserialize__Lcom_google_gwt_user_client_rpc_impl_SerializerBase_2Lcom_google_gwt_user_client_rpc_SerializationStreamReader_2Ljava_lang_Object_2Ljava_lang_String_2V(Unknown source:0)
at Unknown.com_google_gwt_user_client_rpc_impl_AbstractSerializationStreamReader_$readObject__Lcom_google_gwt_user_client_rpc_impl_AbstractSerializationStreamReader_2Ljava_lang_Object_2(Unknown source:0)
at Unknown.com_google_gwt_user_client_rpc_impl_RequestCallbackAdapter$ResponseReader$8_read__Lcom_google_gwt_user_client_rpc_SerializationStreamReader_2Ljava_lang_Object_2(Unknown source:0)
at Unknown.com_google_gwt_user_client_rpc_impl_RequestCallbackAdapter_onResponseReceived__Lcom_google_gwt_http_client_Request_2Lcom_google_gwt_http_client_Response_2V(Unknown source:0)
at Unknown.com_google_gwt_http_client_Request_$fireOnResponseReceived__Lcom_google_gwt_http_client_Request_2Lcom_google_gwt_http_client_RequestCallback_2V(Unknown source:0)
at Unknown.com_google_gwt_http_client_RequestBuilder$1_onReadyStateChange__Lcom_google_gwt_xhr_client_XMLHttpRequest_2V(Unknown source:0)
at Unknown.anonymous(Unknown source:0)
at Unknown.com_google_gwt_core_client_impl_Impl_entry0__Ljava_lang_Object_2Ljava_lang_Object_2Ljava_lang_Object_2Ljava_lang_Object_2(Unknown source:0)
at Unknown.anonymous(Unknown source:0)
at Unknown.handleEvent(Unknown source:0)
at Unknown.anonymous(Unknown source:0)



Any idea what might cause this? The weird thing is that the code works fine in GWT DEV mode, but only fails when I do a proper build/deploy.

Using GXT 2.1.0, GWT 2.0.0. GWT-Math 2.1

ssenecal
24 Jan 2010, 9:47 PM
One thing I should add is that BigDecimal and BigInteger both appear in all of my generated *.gwt.rpc files in the final deployment. I assume that means they should be serializable.

becevka
24 Jan 2010, 10:07 PM
http://code.google.com/p/google-web-toolkit/issues/detail?id=4460&q=milestone%3D2_0_1&sort=milestone
Maybe that helps.

ssenecal
24 Jan 2010, 10:25 PM
Sounds plausible. One thing I have noticed is that the exception notes "java.math.BigDecimal/1680160536" while the gwt.rpc files contain "java.math.BigDecimal/3109731104".

I'm not sure of the significance of the number at the end of the classname, but the fact that they are different concerns me.

ssenecal
24 Jan 2010, 11:28 PM
Yes, that was in fact the problem. The "solution" was to include the BigDecimal_CustomFieldSerializer.class and BigInteger_CustomFieldSerializer.class in gwt-servlet.jar. It appears as if a proper solution will be included in GWT 2.0.1 (http://code.google.com/p/google-web-toolkit/issues/detail?id=4460&q=milestone%3D2_0_1&sort=milestone) , but until then you need a hacked build.

Thanks for pointing me to that thread!

becevka
24 Jan 2010, 11:39 PM
Actually I have solved this problem with rebuilding gwt libs for my project including patch to SerializabilityUtil class. Another possibility is just to replace this class in gwt-servlet.jar.

ssenecal
24 Jan 2010, 11:40 PM
Yes, but the others sounded like too much work ;)