English 中文(简体)
gwt 序列化政策是代同模式的。
原标题:gwt serialization policy hosted mode out of sync

在以东道方式管理我的WT申请(gwt 2.0.4)时,我收到了GWT序列化例外:

INFO: GwtRpcEventSrvc: ERROR: The serialization policy file  /84EC7BA65AF8175BAA99B47877FDE163.gwt.rpc  was not found; did you forget to include it in this deployment?

SEVERE: GwtRpcEventSrvc: WARNING: Failed to get the SerializationPolicy  84EC7BA65AF8175BAA99B47877FDE163  for module  http://host:19980/MYAPP/ ; a legacy, 1.3.3 compatible, serialization policy will be used.  Youmay experience SerializationExceptions as a result.

SEVERE: Exception while dispatching incoming RPC call
Throwable occurred: com.google.gwt.user.client.rpc.SerializationException: java.lang.reflect.InvocationTargetException
.at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeWithCustomSerializer(ServerSerializationStreamWriter.java:760)
.at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeImpl(ServerSerializationStreamWriter.java:723)
.at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:612)
.at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:129)
.at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter$ValueWriter$8.write(ServerSerializationStreamWriter.java:152)
...
Caused by: com.google.gwt.user.client.rpc.SerializationException: Type  com.mypackage.data.MyData  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.: instance = com.mypackage.data.MyData@1b061b06
.at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:610)
.at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:129)
.at com.google.gwt.user.client.rpc.core.java.util.Collection_CustomFieldSerializerBase.serialize(Collection_CustomFieldSerializerBase.java:43)
.at com.google.gwt.user.client.rpc.core.java.util.LinkedList_CustomFieldSerializer.serialize(LinkedList_CustomFieldSerializer.java:36)
.... 33 more

Hosted mode generates serializations policy files (*.gwt.rpc) with different md5 that those that were created during GWT compilation - these are deployed on my server. GWT is missing serialization policy file that hosted mode client wants.

在以非敌对方式行事时,一切都是罚款的。

我试图通过Ant或Eclipse debug配置启动模式,结果相同。 GWT汇编班次和东道模式班次(包括)相同。

GWT Compilation Ant script:

<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
  <classpath>
    <pathelement location="${basedir}/src" />
    <pathelement location="${dir.build.root}/ProjectA/src" />
    <pathelement location="${dir.build.root}/ProjectB/src" />
    <pathelement location="${dir.build.root}/ProjectC/src" />
    <pathelement location="${dir.build.root}/ProjectD/src" />
    <pathelement location="${dir.build.root}/ProjectE/src" />
    <pathelement location="${dir.root}/ProjectD/src" />
    <pathelement location="${dir.root}/THIRDPARTY/build/athirdparty.jar" />
    <pathelement location="${dir.commons.gwtcompiler}/gwt-user.jar" />
    <pathelement location="${dir.commons.gwtcompiler}/gwt-dev.jar" />
    <pathelement location="../ExternalLibs/libs/gwt-log-3.0.0.jar" />
<!-- JAXB API sources needed for GWT compilation of JAXB annotated classes -->
    <pathelement location="../ExternalLibs/nonshipjars/jaxb-api-src.zip" />
  </classpath>
  <jvmarg value="-Xmx1g" />
  <jvmarg value="-Dgwt.nowarn.metadata" />
  <arg line="-localWorkers 2 -style OBF" />
  <arg line="-war ${basedir}/www" />
  <arg line="-extra ${basedir}/build" />
  <arg value="com.myapp.Main" />
</java>

主办模式发射——文字:

<target name="hosted" description="Run hosted mode">
  <java failonerror="true" fork="true" classname="com.google.gwt.dev.HostedMode">
    <classpath>
        <pathelement location="${basedir}/src" />
        <pathelement location="${dir.build.root}/ProjectA/src" />
        <pathelement location="${dir.build.root}/ProjectB/src" />
        <pathelement location="${dir.build.root}/ProjectC/src" />
        <pathelement location="${dir.build.root}/ProjectD/src" />
        <pathelement location="${dir.build.root}/ProjectE/src" />
        <pathelement location="${dir.root}/ProjectD/src" />
        <pathelement location="${dir.root}/THIRDPARTY/build/athirdparty.jar" />
        <pathelement location="${dir.commons.gwtcompiler}/gwt-user.jar" />
        <pathelement location="${dir.commons.gwtcompiler}/gwt-dev.jar" />
        <pathelement location="../ExternalLibs/libs/gwt-log-3.0.0.jar" />
    <!-- JAXB API sources needed for GWT compilation of JAXB annotated classes -->
        <pathelement location="../ExternalLibs/nonshipjars/jaxb-api-src.zip" />
    </classpath>
    <jvmarg value="-Xmx1g" />
    <jvmarg value="-Dgwt.nowarn.metadata" />
    <arg line="com.myapp.Main" />
    <arg line="-startupUrl" />
    <arg line=" http://host:19980/MYAPP/Main.html" />
    <arg line="-whitelist" />
    <arg line="^http[:][/][/]host[:]19980" />
    <arg line="-whitelist" />
    <arg line=" ^http[:][/][/]localhost" />
    <arg line="-whitelist" />
    <arg line="^http[:][/][/]127.0.0.1" />
    <arg line="-port" />
    <arg line="8080" />
    <arg line="-noserver" />
    <arg line="-logLevel" />
    <arg line="DEBUG" />
  </java>
</target>

RPC 方法签名:

public List<MyData> getSmpeWorkDddefZonesData(String processId);

MyData 下定义(在作为非GWT项目――数据级的项目E中宣布):

package com.mypackage.data;

import java.io.Serializable;

public interface MyData extends Serializable {...

MyData is linked in module inherited from another GWT module: com.mypackage.Data.gwt.xml:

<module>
  <source path="data" />
</module>

主要模块com.myapp.Main.gwt.xml:

...
  <inherits name="com.mypackage.Data" />
...

如何使东道国产生相同的序列化政策档案?

问题回答

我早就遇到同样的问题。 我看到的唯一解决办法是确保双方拥有同样的.gwt.rpc文档。

That means, everytime you start or reload Dev Mode, you have to replace the old .gwt.rpc files deployed on your web server with the newly generated ones.

或者,你将Dev Mode战争产出目录放在网络服务器的背景下。 并确保网络服务器自动投放。 因此,每当文件由Devlow改动时,网络服务器自动重载档案。

根据我在<代码>com.google.gwt.user.rebind.rpc.ProxyCreator中看到的情况。 GWT按其内容(md5)生成序列化政策的名称.gwt.rpc

因此,出于某种原因,超级发展模式的序列化政策不同于正常建筑期间产生的序列化政策。

下面的做法给我留下了问题:

  1. Open the serialization policy .gwt.rpc file generated for the regular build
  2. Open the serialization policy .gwt.rpc file generated for the Super Dev Mode. You can find where it is by looking into the work directory printed at Super Dev Mode startup. E.g. in my case it was: "workDir: C:Usersyour_userAppDataLocalTempgwt-codeserver-5658052675265790575.tmp"
  3. Compare the 2 files - this could give you a pretty good hint regarding where the problem might be. In my case 2 unneeded types were getting added to the serialization policy and I could simply remove them from the project completely.
  4. After fixing the discrepancies the .gwt.rpc files name should be identical again and the problem will be fixed :)




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签