GWT Serialization error with HTML String content

313 views
Skip to first unread message

dhoffer

unread,
Apr 30, 2012, 8:36:48 PM4/30/12
to Google Web Toolkit
Using GWT 2.4. I'm trying to track down the root cause of this...not
sure if I'm doing something wrong or this is a bug someplace.

30 Apr 2012 13:54:48,953 ERROR AtmosphereHandler []: Failed to
deserialize message
com.google.gwt.user.client.rpc.SerializationException: Too few tokens
in RPC request
at
com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader.extract(ServerSerializationStreamReader.java:
809)
at
com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader.deserializeStringTable(ServerSerializationStreamReader.java:
735)
at
com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader.prepareToRead(ServerSerializationStreamReader.java:
449)
at
org.atmosphere.gwt.server.AtmosphereGwtHandler.deserialize(AtmosphereGwtHandler.java:
283)
at
ipt.tas.chatdashboard.ui.gwt.server.AtmosphereHandler.deserialize(AtmosphereHandler.java:
68)
at
org.atmosphere.gwt.server.AtmosphereGwtHandler.doServerMessage(AtmosphereGwtHandler.java:
237)
at
org.atmosphere.gwt.server.AtmosphereGwtHandler.onRequest(AtmosphereGwtHandler.java:
183)
at
org.atmosphere.cpr.AsynchronousProcessor.action(AsynchronousProcessor.java:
217)
at
org.atmosphere.cpr.AsynchronousProcessor.suspended(AsynchronousProcessor.java:
166)
at
org.atmosphere.container.JettyCometSupport.service(JettyCometSupport.java:
99)
at
org.atmosphere.cpr.AtmosphereFramework.doCometSupport(AtmosphereFramework.java:
1162)
at
org.atmosphere.cpr.AtmosphereServlet.doPost(AtmosphereServlet.java:
293)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at
org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:
362)
at
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:
216)
at
org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:
181)
at
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:
729)
at
org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:
152)
at
org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:
49)
at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:
152)
at org.mortbay.jetty.Server.handle(Server.java:324)
at
org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:
505)
at org.mortbay.jetty.HttpConnection
$RequestHandler.content(HttpConnection.java:843)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:
211)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:
380)
at
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:
395)
at org.mortbay.thread.QueuedThreadPool
$PoolThread.run(QueuedThreadPool.java:488)
Caused by: java.lang.IndexOutOfBoundsException: Index: 11, Size: 11
at java.util.ArrayList.rangeCheck(ArrayList.java:604)
at java.util.ArrayList.get(ArrayList.java:382)
at
com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader.extract(ServerSerializationStreamReader.java:
807)
... 30 more

This happens when I send the following HTML as a string to the
Atmosphere comet framework but that framework just seems to pass this
to GWT's ClientSerializationStreamWriter &
ServerSerializationStreamReader. Here is the string that fails:
<div style="font-family: Arial; font-size: 10pt;"><div
class="chatline" style="text-indent:-10px; margin-left:10px;"><span
class="timestamp-self" style="color:#FF0000;">(Apr 30 2012 15:11:33) </
span><span class="from-self" style="color:#FF0000;">tom: </span><span
class="message">a</span></div>
</div>

But this string works fine with same method:
<div style="font-family: Arial; font-size: 10pt;"></div>

What's going on here? Is there some known restrictions sending HTML
with GWT serialization? How to fix this?

-Dave


Joseph Lust

unread,
May 1, 2012, 10:17:02 AM5/1/12
to google-we...@googlegroups.com
Dave,

I know this is not exactly the answer you're looking for, but why are you trying to serialize and send HTML over the wire like that? Why not use a Uibinder to build that HTML and just send the dynamic part over the wire, which is "Apr 30 2012 15:11:33?" This is how such work is typically done. Further, you just need to send a date object, so you can leave the formatting to the UiBinder on the clientside as well.

I hope that helps as HTML is not typically parroted like that in GWT.

Sincerely,
Joseph

dhoffer

unread,
May 3, 2012, 9:15:32 AM5/3/12
to Google Web Toolkit
Joseph,

In this case I'm just trying to send some HTML to the server so it can
be saved as a log file for the user, but the issue here really has
nothing to do with HTML, it is due to new line characters in the
string...could be any string. I found and fixed the problem. It was
due to some Atmosphere comet code that assumed the string would not
have any new line chars...all is working now with that fixed.

-Dave

Joseph Lust

unread,
May 3, 2012, 10:08:34 AM5/3/12
to google-we...@googlegroups.com
Touche, glad you got it sorted. I'll be on the lookout for newline characters in the future.

Sincerely,
Joseph
Reply all
Reply to author
Forward
0 new messages