Thursday, June 18, 2009

GWT - Application is not up to date erred message

GWT has a very weird way of dealing with serializable types. If a type is not serializable (read in the docs what that means) and you try to use it with the remoting support you'll get all sorts of weird exceptions. I have explained one situation in a previous post.

In the same ideea, if you have a remote exception (that implements IsSerializable cause you want to send it over the wire right ?) BUT you are unfortunate enough to forget that ALL google serializable types MUST have an empty constructor (as per their docs) you will get a

IncompatibleRemoteServiceException

with the message "Your application is not up to date, hit refresh in your browser bla bla bla". And you will hit refresh a lot of times with no result.

If you read the IncompatibleRemoteserviceException javadoc you'll see it is thrown in the case of sending over the wire a "not so" serializable type. So an exception implementing IsSerializable it is not yet serializable if you DON'T ADD A NO ARGS CONSTRUCTOR to it.

I'd wish GWT would check at compile time for all serializable types used (or at least declared) and at least give a warning if not fail the compilation altogether.

Remember: a GWT serializable type MUST have a no args constructor (unless you don't specify any of them) and that's for all your serializable type hierarchy.