My problems with RemoteServiceServlet.doGetSerializationPolicy(..)

313 views
Skip to first unread message

demawi

unread,
May 12, 2008, 8:12:29 PM5/12/08
to Google Web Toolkit
When I am running a Tomcat with a deployed application to "/myApp1"
And a WebServer having a proxy set from "http://myServer:80/myApps/
myApp1" to "http://localhost:8080/myApp1"
Then I am running into a big problem with the standard
RemoteServiceServlet.doGetSerializationPolicy(..) - method.

The code:
if (modulePath == null || !modulePath.startsWith(contextPath)) {
String message = "ERROR: The module path requested, "
+ modulePath
+ ", is not in the same web application as this servlet, "
+ contextPath
+ ". Your module may not be properly configured or your
client and server code maybe out of date.";
getServletContext().log(message);
} else {
... policy-file-retrieving ...
}
where modulePath = "/myApps/myApp1" and contextPath = "/myApp1", will
log the error-message and won´t try to get any policy file.

Currently I overwrite this method and retrieve the policy file just
with:
String string =
SerializationPolicyLoader.getSerializationPolicyFileName("http://
localhost:"+request.getServerPort()+modulePath+strongName);
Input Stream is = new URL(string).openStream();

Edit all hosted GWT-Application-Servlets doesn´t sound reasonable for
me, but as far as I can see I can not configure another policy-file-
retrieving for all applications!?

meng

unread,
May 12, 2008, 8:19:36 PM5/12/08
to Google Web Toolkit
hi demawi ,

> Currently I overwrite this method and retrieve the policy file just
> with:
> String string =
> SerializationPolicyLoader.getSerializationPolicyFileName("http://
> localhost:"+request.getServerPort()+modulePath+strongName);
> Input Stream is = new URL(string).openStream();
>

is it working? where did you put the above code snippet?

I am having similar problem as well, i put gwt on apache and use
proxy_ajp to connect to my app.

demawi

unread,
May 13, 2008, 6:04:50 AM5/13/08
to Google Web Toolkit
hi,

yes it´s working within hosted mode and all my tomcat-deployed
applications.

I just copied the code from
RemoteServiceServlet.doGetSerializationPolicy(..) - method to my own
implementation. Then I removed the
> if (modulePath == null || !modulePath.startsWith(contextPath))
- condition and now using my code snippet within the remaining block.

stuckagain

unread,
May 14, 2008, 4:13:36 AM5/14/08
to Google Web Toolkit
Hi,

I stumbled upon a similar issue because I have a generic servlet that
forwards the calls to the actual RPC servlet.
According to michael mendez and the javadoc (the person in charge of
RPC) you are indeed required to override
the doGetSerializationPolicy method in the RemoteServlet class. We can
do lots of wacky things in filters, servlets or proxies, so its
impossible for the RPCServlet to be able to locate the depending files
correctly. Although if he would use the request path and not the path
hidden in the serialized object, then he would already avoid a lot of
issues in real world situations.

In my case I calculate the real moduleBaseURL and then call the super
with this new path. I've implemented this in an abstract class and all
my RPC servlets derive from this class, so no need to duplicate the
effort in all servlets.

David

demawi

unread,
May 14, 2008, 4:42:10 AM5/14/08
to Google Web Toolkit
How do you calculate the real moduleBaseURL? With the URL:
"localhost:"+request.getServerPort()+modulePath" I am also trying to
go the same way than the request.

Of course it´s possible to extend an abstract class with the correct
"doGetSerializationPolicy"-implementation. But whenever we forget
this, we are running into this issue.
I am also hosting some projects for other people and I can not alter
their code. So I am interested in a general solution, which can be
committed to GWT.

demawi

unread,
May 19, 2008, 2:27:32 PM5/19/08
to Google Web Toolkit
Hmm.. I think:
String string =
SerializationPolicyLoader.getSerializationPolicyFileName("http://
localhost:"+request.getServerPort()+modulePath+strongName);
is not the best solution. Because of problems with the server port.

Now I´m using:
String requestURL = request.getRequestURL().toString();
requestURL = requestURL.substring(0, requestURL.lastIndexOf("/")
+ 1);
String string =
SerializationPolicyLoader.getSerializationPolicyFileName(requestURL +
strongName);
to follow the servlet URL.
Reply all
Reply to author
Forward
0 new messages