Intermitant serialization exception with GWT Dev mode and external server

蹲街弑〆低调 提交于 2019-12-11 02:04:29

问题


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!


回答1:


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



回答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.



来源:https://stackoverflow.com/questions/18021711/intermitant-serialization-exception-with-gwt-dev-mode-and-external-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!