Friday, April 26, 2013

GWT 'the response could not be deserialized' in Dev Mode

My current job has me doing GWT for the front-end technologies and I ran across this error the other day and couldn't figure it out:

com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException: The response could not be deserialized
I Googled it and found that the main solution was that this was a common problem and almost always happened because some of the classes in the shared package that you were sending to the client hadn't implemented IsSerializable or Serializable.

I was perplexed by this because I had made no code changes to these objects since the last time I ran it. I double checked that they did indeed implement one of the right interfaces, and they did.

Also, it was working fine when it wasn't in Dev Mode (i.e. adding the 'gwt.codesvr=127.0.0.1:9997' to the end of it and letting the GWT Plugin compile the front end stuff on the fly).  The only thing I'd changed is that I had an updated copy of our QA database.

So, I decided to do a 'printStackTrace' on the Throwable object it was returning, to get to the heart of the matter. At the bottom of the stack trace, I found this:

Caused by: java.lang.RuntimeException: FAILED ASSERTION
at com.google.gwt.dev.js.rhino.Context.codeBug(Context.java:769)
at com.google.gwt.dev.js.rhino.Parser.sourceAddString(Parser.java:1424)
at com.google.gwt.dev.js.rhino.Parser.primaryExpr(Parser.java:1342)
at com.google.gwt.dev.js.rhino.Parser.memberExpr(Parser.java:1163)
at com.google.gwt.dev.js.rhino.Parser.unaryExpr(Parser.java:1079)

I put a break point in there and found that one of the Strings that was being passed from the server to the client was too big!  I shorted the String (it was a field in the database) and it worked!

It's strange that this only happens in Dev-Mode.  I think that GWT uses different libraries to compile on-the-fly than it does to actually compile for the end product.  

No comments: