首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >GWT SerializationException,但只有在涉及马拉松-LB的情况下。

GWT SerializationException,但只有在涉及马拉松-LB的情况下。
EN

Stack Overflow用户
提问于 2018-02-01 19:34:26
回答 2查看 74关注 0票数 1

我有一个GWT网络应用程序运行良好-除非我把它放在一个Marathon-LB负载平衡器和使用HTTPS

失败发生在一个岗位上。

  • 当webapp不在Marathon-LB后面时,帖子将得到200 OK。
  • 但是,当它落后于Marathon-LB时,GWT SerializationException会出现一个内部服务器错误,而POST将得到500个错误。

对于故障情况,tomcat的服务器日志中的堆栈跟踪如下。请注意,线程是https-jsse-nio-8080-exec-6

代码语言:javascript
复制
01-Feb-2018 18:43:39.863 SEVERE [https-jsse-nio-8080-exec-6] org.apache.catalina.core.ApplicationContext.log Exception while dispatching incoming RPC call
com.google.gwt.user.client.rpc.SerializationException: Type 'com.company.SomeGwtSerializableClass' was not assignable to 'com.google.gwt.user.client.rpc.IsSerializ
able' and did not have a custom field serializer.For security purposes, this type will not be serialized.: instance = com.company.SomeGwtSerializableClass@6ce9a6c9
        at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:667)
        at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:130)
        at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter$ValueWriter$8.write(ServerSerializationStreamWriter.java:153)
        at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeValue(ServerSerializationStreamWriter.java:587)

我怀疑问题在于运行Marathon-LB的码头容器和运行webapp服务的Tomcat的码头容器之间的信任证书。

对如何调试这一点有什么建议吗?例如,如何确定Marathon-LB容器信任webapp容器?

谢谢!

EN

回答 2

Stack Overflow用户

发布于 2018-02-02 13:45:58

负载均衡器可能破坏GWT的两种可能方法(至少):

  • 提供错误的内容:这种情况可能以几种方式发生,比如负载平衡器缓存了什么,或者它背后的一个服务器正在提供过期文件,然后该客户端被要求连接到最新的服务器。
  • 破坏来电:负载平衡器可能会犯错误或“帮助”并破坏某些东西--掉头、将请求中的moduleBaseUrl重写为其他东西等等。

无论哪种情况,大多数情况都涉及到找不到正确的序列化策略文件(编译后的输出中的.gwt.rpc文件),这反过来又是由com.google.gwt.user.server.rpc.RemoteServiceServlet#loadSerializationPolicy方法中的一些错误引起的。据我所知,所有这些错误都会导致一些错误被记录下来,尽管这可能是一个不同的文件。可能检查其他服务器日志文件以查看是否出错,或者在负载均衡器后面附加和调试该方法,并确保它在发生错误时返回实际策略。还请记住,这些策略文件是缓存的,因此在重新启动服务器webapp之前,错误只会发生一次。

票数 1
EN

Stack Overflow用户

发布于 2018-02-12 09:26:30

我认为你的问题是特定于RPC的。

作为某种验证/保护的一部分,RPC尝试服务器端通过getServletContext().getResourceAsStream加载这些序列化策略。

代码语言:javascript
复制
/*
 * Check that the module path must be in the same web app as the servlet
 * itself. If you need to implement a scheme different than this, override
 * this method.
 */
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.";
  servlet.log(message);
} else {
  // Strip off the context path from the module base URL. It should be a
  // strict prefix.
  String contextRelativePath = modulePath.substring(contextPath.length());

  String serializationPolicyFilePath = SerializationPolicyLoader.getSerializationPolicyFileName(contextRelativePath
      + strongName);

  // Open the RPC resource file and read its contents.
  InputStream is = servlet.getServletContext().getResourceAsStream(
      serializationPolicyFilePath);

你可以在这里看到这一点:

https://github.com/stephenh/gwt/blob/master/user/src/com/google/gwt/user/server/rpc/RemoteServiceServlet.java

上面的问题是serializationPolicyFilePath是基于客户端路径构建的。因此,如果您的客户端路径和服务器路径不同,您将遇到麻烦。

在这方面我遇到了很多麻烦,为了能够从不同的位置加载策略文件,我最终通过RemoteServiceServlet覆盖了一些东西。

Edit1:添加了缺失的额外代码行;还忘记提到问题可能在getResourcesAsStream调用中,或者在!modulePath.startsWith(contextPath)比较中。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48570423

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档