How GWT RPC loads the serialization policy files?

maasg picture maasg · Jun 21, 2012 · Viewed 11.2k times · Source

I'm researching a solution for an issue with GWT and OSGi+PAX-Web. The particular problem is that GWT cannot load the serialization policy file, giving the following error:

ERROR: The serialization policy file '/ctx/ctx/6ExxxxxxxxxxxxxxxxF.gwt.rpc' was not found; did you forget to include it in this deployment?

The problem lies somewhere between Equinox OSGi and PAX-WEB.

To find a solution, I would like to better understand how GWT-RPC is loading the serialization policy files.

  • What is their lifecycle? When are they loaded? (I see it's on server startup. Any particularities in the lifecycle? Reload?)
  • How GWT loads this file in its stack? At what point in the call stack of a request? How does GWT knows where to load them from? Can I tell GWT where it should look for this file?

(disclaimer: I've read the gwt docs on the generated files [2]. I'm looking for more low-level details: I've the impressions that the error we are having has to deal with HttpContext.getResource())

Answer

Thomas Broyer picture Thomas Broyer · Jun 21, 2012

It's all in RemoteServiceServlet.

What is their lifecycle? When are they loaded? (I see it's on server startup. Any particularities in the lifecycle? Reload?)

They're loaded on first use (first request received) and cached in a field of the servlet, so their lifecycle is tied to the one of the servlet itself.

How GWT loads this file in its stack? At what point in the call stack of a request? How does GWT knows where to load them from? Can I tell GWT where it should look for this file?

servlet.getServletContext().getResourceAsStream. You can customize this by overriding doGetSerializationPolicy (as said in the JavaDoc).
The file name (resource URL) is built from the request's path and X-GWT-Permutation request header.