3

I have a GWT app which runs pretty much flawlessly in Dev mode with GWT's embedded jetty server.

However, I need to move over to using an external jetty server (For various reasons). I followed the GWT documentation Compile & Debug for external server setup exactly.

My app runs, however 2/3 of the time on load I get a serialization exception similar to this (On the server side):

com.google.gwt.user.client.rpc.SerializationException: Type 'my.package.impl.ContentTypeImpl' was not assignable to 'com.google.gwt.user.client.rpc.IsSerializable' and did not have a custom field serializer.For security purposes, this type will not be serialized.: instance = my.package.impl.ContentTypeImpl@5e5edf72

I am sure that this particular class is serializable, and I have ensured that I compiled my application and moved the static assets into my external servers war directory. Like I said, it works about every third time I refresh the browser.

Any suggestions?

Thanks!

Casey Jordan
  • 1,204
  • 1
  • 20
  • 39

2 Answers2

3

from: http://www.gwtproject.org/doc/latest/tutorial/RPC.html#serialize

A class is serializable if it meets these three requirements:

  1. It implements either Java Serializable or GWT IsSerializable interface, either directly, or because it derives from a superclass that does. <--
  2. Its non-final, non-transient instance fields are themselves serializable, and
  3. It has a default (zero argument) constructor with any access modifier (e.g. private Foo(){} will work
Vjeetje
  • 5,314
  • 5
  • 35
  • 57
  • Thanks but as I said before I am positive this class meets the critera for serialization as it has been used for months in both regular GWT dev mode and production mode. This problem only happens intermittently with the noserver setup. Any other thoughts? – Casey Jordan Aug 03 '13 at 02:25
  • Did you use com.google.gwt.user.client.rpc.IsSerializable instead of java.io.Serializable? Other possible reason is a desync of a cached version. Try copying back latest files to server and clearing browser cache. – Vjeetje Aug 03 '13 at 14:18
  • I am pretty sure that everything I use is java.io.Serializable but there is a lot of code so I will go back and make sure. Out of curiosity, is using com.google.gwt.user.client.rpc.IsSerializable no good? The documentation says either of this should work, no? – Casey Jordan Aug 08 '13 at 18:11
  • You should use com.google.gwt.user.client.rpc.IsSerializable instead of java.io.Serializable. There are other people with same problem that solved it with changing interfaces. – Vjeetje Aug 09 '13 at 11:50
  • 1
    Interesting! I started changing some of my classes over to using IsSerializable and it removed errors for those classes. Does this mean that classes which are implement IsSerializable are automatically whitelisted and don't need to be generated into the gwt.rpc files? – Casey Jordan Aug 12 '13 at 00:45
  • GWT compile should handle that for you. – Vjeetje Aug 12 '13 at 09:14
  • Well that is the thing, I am trying to get around having to recompile everytime I change an async interface because our application is very large and it can take 10 min or more. So I was wondering if using IsSerializable would make subsequent compiles unnecessary. Thanks for the help! – Casey Jordan Aug 12 '13 at 13:09
2

My guess is that you are using a separate war directory in your external server, have copied all of your static content over (including the *.gwt.rpc files) to that war directory, and then changed something about the serializable models that you are passing across your RPC calls. Whenever these models change the generated .gwt.rpc files will have changed. Your server would be using one variation of the serialization policies and your client java debugging would be using a different one.

I can think of two options:

  1. Make sure to copy the .gwt.rpc files over to the server war directory. You could create a custom ant task to do this.

  2. Configure your external web server to point to the same war directory that you use for internal GWT debugging. That way when GWT generates changes they are automatically in the right place.

Option #2 is the one I go with when dealing with large complex systems that require an external server.

xsee
  • 1,173
  • 1
  • 9
  • 12
  • This was my thought as well but I am using the same war directory. However the classes that the system is complaining about are in a seperate maven module. I am wondering if there is something that Intellij does when running in complete dev mode that it doesn't when the noserver flag is set? – Casey Jordan Aug 03 '13 at 22:04
  • xsee, Is there anything special I have to do in order to make this happen. – Casey Jordan Aug 08 '13 at 02:54
  • Hmmm, I don't use IntelliJ so it's hard for me to speculate but I doubt it is doing anything that would be too different from what eclipse does in this scenario. I wonder if your external Jetty server is caching the serialization policies? I haven't used an external Jetty in awhile so I don't have any configuration files handy to reference. – xsee Aug 08 '13 at 15:00
  • Ok, thanks. I think it may be related to the compiler setup. I am investigating ;) – Casey Jordan Aug 08 '13 at 18:09