Tuesday, July 28, 2015

Re: GWT app doesn't work behind reverse proxy

I have spent four hours yesterday investigating the issue with serialization. In my case all objects do implement 'IsSerializable', which should force GWT to use the old serialization. And it works fine on the server side, but on the client side (i.e. in web browser) it looks like it does not know about the current used serialization policy and fails deserializing. After hours of reverse engineering I found out that `StandardSerializationPolicy` adds some array to the serialized object, which is expected to appear on the client side. But `LegacySerializationPolicy` does not add such array, which looks like the reason of failure on the client side.

It does not happen for all classes of objects in my case, but a particular one of them in has failed for sure. I don't know whether this is a bug or not, but finally I used solution from this answer: http://stackoverflow.com/a/25025144/1627984 . I am using latest publicly available at the moment of writing stable version of GWT 2.7.0. You can find my change in this commit of github: https://github.com/vitalidze/traccar-web/commit/1c7f257f93fab8e76dc2b6606cc4cc5ea7136136

Hope this helps.

Kind regards, Vitaly Litvak.

четверг, 9 июля 2015 г., 18:54:29 UTC+3 пользователь dhoffer написал:
Jens,

Thanks for the reply and information, it sounds like there is a workaround then for the GWT part but we still have the same/similar issue with Tomcat's authentication.  We need to solve that too else its only a partial solution.

Btw, regarding the GWT serialization issue...I read online some say a way around this is to use IsSerializable instead of Serializable to mark objects going across the wire but its not clear if that 'trick' still works or not.  Also some say to drop GWT RPC and use JSON instead that doesn't have the same issue.  I don't really care what the format of the data is going across the wire, I just need the results to work.  Is there an easy way to switch the RPC format to JSON or some other format that doesn't have this issue?

-Dave



On Thu, Jul 9, 2015 at 9:29 AM, Jens <jens.ne...@gmail.com> wrote:
The "issue" is that GWT will send you the moduleBaseURL as payload from the client to the server and the server uses that value to find the RPC policy file on disk. When you use a reverse proxy then the moduleBaseURL will not change when passing the proxy, it will always be http://domain.com/appname/<modulename> or http://domain.com/<modulename> (depends on how you deploy your app). Because of this GWT's default implementation of RemoteServiceServlet.doGetSerializationPolicy() does not work anymore as it tries to match the moduleBaseURL with the server context path which can now be totally different because of the proxy.

So you either have to write custom code to find the RPC policy file on your server (thats what I also do at the moment) or you can try overriding the default moduleBaseURL on the client by using <meta name='gwt:property' content='baseUrl=/appcontext/myapp'> in your host page.

Also keep in mind when you use a reverse proxy that you might need to rewrite cookie domains / paths as well. In apache you can do that with ProxyPassReverseCookieDomain and ProxyPassReverseCookiePath.


-- J.

--
You received this message because you are subscribed to a topic in the Google Groups "Google Web Toolkit" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-web-toolkit/Zi_dtUEePlY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-we...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment