如何在多个客户端模块/应用程序之间共享 GWT RPC RemoteServiceServlet
我有几个 GWT 模块和 Web 应用程序在 Jetty 中运行。他们每个人都想使用我的 LoginService
RPC 接口,因此我将此接口及其 servlet 实现放在一个公共模块中。我从根 Web 上下文提供 servlet (LoginServiceImpl
),并且 web.xml
在 url“/loginService”处公开它。在另一个 GWT 模块中,要使用此服务,我必须设置入口点,如下所示...
LoginServiceAsync loginService = GWT.create(LoginService.class);
ServiceDefTarget t = (ServiceDefTarget)loginService;
t.setServiceEntryPoint("/loginService");
现在,尝试使用 loginService 的模块称为 discussions,我收到此错误服务器。
ERROR: The serialization policy file
'/discussions/discussions/7B344C69AD493C1EC707EC98FE148AA0.gwt.rpc' was not found;
did you forget to include it in this deployment?
因此,servlet 报告了一个提到客户端(讨论模块)的错误。我猜测 RPC 管道从客户端传递了这个 .rpc 文件的名称,而 servlet 现在正在寻找它。 (?) 作为实验,我将讨论模块中的 *.gwt.rpc 文件复制到根 Web 上下文中,以便 servlet 可以找到它们。这确实阻止了错误。但我仍然收到另一个错误:
com.google.gwt.user.client.rpc.SerializationException: Type
'mystuff.web.shared.User' 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.: ...
此类是可序列化的;它以前在其他模块中工作过,所以现在我迷路了。
从多个客户端模块使用 LoginService
的正确方法是什么?
更新:
此错误出现在托管开发模式中,并在完整编译后消失。也许这与 gwt 序列化策略托管模式不同步 .如果我能更好地重现问题,我会再次更新。
I have several GWT modules and web apps running in Jetty. They each want to use my LoginService
RPC interface, so I put this interface and its servlet implementation in a common module. I serve the servlet (LoginServiceImpl
) from my root web context, and web.xml
exposes it at the url "/loginService". In a another GWT module, to use this service, I had to set the entry point, like this...
LoginServiceAsync loginService = GWT.create(LoginService.class);
ServiceDefTarget t = (ServiceDefTarget)loginService;
t.setServiceEntryPoint("/loginService");
Now, the module trying to use the loginService is called discussions, and I get this error on the server.
ERROR: The serialization policy file
'/discussions/discussions/7B344C69AD493C1EC707EC98FE148AA0.gwt.rpc' was not found;
did you forget to include it in this deployment?
So the servlet is reporting an error that mentions the client (the discussions module). I'm guessing that the RPC plumbing passed the name of this .rpc file through from the client, and the servlet is now looking for it. (?) As an experiment, I copied, the *.gwt.rpc files from the discussions module into the root web context, so the servlet could find them. This did stop the error. But I still get another error:
com.google.gwt.user.client.rpc.SerializationException: Type
'mystuff.web.shared.User' 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.: ...
This class is serializable; it worked before in other modules, so now I'm lost.
What is the right way to use the LoginService
from multiple clients modules?
Update:
This error was showing up in hosted devmode, and it went away after a full compile. Maybe this is related to gwt serialization policy hosted mode out of sync . I will update again if I can better reproduce the problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请参阅我的答案此处。简短的答案是:您需要在编译时使
mystuff.web.shared.User
源代码可供您的discussions
模块使用。See my answer here. The short answer is: you'll need to make
mystuff.web.shared.User
s source available at compile-time to yourdiscussions
module.