如何在多个客户端模块/应用程序之间共享 GWT RPC RemoteServiceServlet

发布于 2025-01-08 19:19:56 字数 1484 浏览 3 评论 0原文

我有几个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧城烟雨 2025-01-15 19:19:56

请参阅我的答案此处。简短的答案是:您需要在编译时使 mystuff.web.shared.User 源代码可供您的 discussions 模块使用。

See my answer here. The short answer is: you'll need to make mystuff.web.shared.Users source available at compile-time to your discussions module.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文