Friday, April 17, 2009

GWT and Payload

StackTrace
onFailure: rocket.remoting.client.CometException: com.google.gwt.core.client.JavaScriptException: (SyntaxError): Unterminated string constant
number: -2146827273
description: Unterminated string constant
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.ie.IDispatchImpl.callMethod(IDispatchImpl.java:126)
at com.google.gwt.dev.shell.ie.MethodDispatch.invoke(MethodDispatch.java:97)
at com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:294)
at com.google.gwt.dev.shell.ie.IDispatchImpl.method6(IDispatchImpl.java:194)
at org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:117)
at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1925)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2966)
at com.google.gwt.dev.GWTShell.pumpEventLoop(GWTShell.java:720)
at com.google.gwt.dev.GWTShell.run(GWTShell.java:593)
at com.google.gwt.dev.GWTShell.main(GWTShell.java:357)


Possible Issue and Solution

The String you are sending back to the client contains newline or carriage returns in it. This makes the JavaScript gwt handler vomit on the client side.

What I did was replace the newline with a pipe which I then converted back to a newline in my UI display logic.


public CometPayload(String pLogMessage) {
//logMessage = pLogMessage;
logMessage = pLogMessage.replace("\r\n", "").trim();
}