GWT Serialization MyObject java.sql.Timestamp
I have defined MyObject
on client side of my GWT application that implements IsSerializable
, where MyObject{String, Timestamp, Timestamp, String}
.
When make a simple rpc (where AsyncCallback<ArrayList<MyObject>>
), I get the following error:
com.google.gwt.user.client.rpc.StatusCodeException: 500 The call failed on the server; see server log for details
at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:209)
at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287)
at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:395)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:167)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:326)
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:207)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:132)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:214)
at sun.reflect.GeneratedMethodAccessor16.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:167)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:281)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:531)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:352)
at java.lang.Thread.run(Unknown Source)
I tried with only returning one MyObject (as opposed to an ArrayList) withAsyncCallback<MyObject>
, which also resu开发者_StackOverflowlted in the above error.
Finally, I removed the Timestamp properties, so that MyObject{String, String}
, which worked, leading me to believe that there's a problem with serializing java.sql.Timestamp
. Can anybody comment on this and advise me on how best to proceed please?
I checked the server logs and found nothing out of the ordinary.
Edit 1:
I've tested with MyObject{Timestamp}
and that also failed.
Solution so far:
Quite hacky, moved MyObject
to shared folder and declared the Timestamps as transient
, then converted them to longs so that I can create a Timestamp object out of them on client side. Ugly, I know, but it works.
I had a similar error, so I solved adding a empty contructor in this case in MyObject class
public MyObject(){}
I hope this could help somebody.
Bye.
I' quite sure serializing a java.sql.Timestamp
is possible in GWT. If in doubt read up on GWT's serializable types:
http://code.google.com/webtoolkit/doc/latest/DevGuideServerCommunication.html#DevGuideSerializableTypes
So I assume your call fails in your method on server-side, not during serialization. Did you try to attach a debugger to see what is happening in your server-side method?
精彩评论