SerializationException while desalinization com.google.appengine.api.datastore.Key GWT

Posted

技术标签:

【中文标题】SerializationException while desalinization com.google.appengine.api.datastore.Key GWT【英文标题】: 【发布时间】:2013-05-17 14:51:35 【问题描述】:

我有一个 RPC 调用:

@Override
public void onSuccess(Void result) 
        Window.alert("SuccessElse");
          userService.getUser("103419018118650635943", new AsyncCallback<User>() 

                @Override
                public void onFailure(Throwable e) 
                    Window.alert("FailAgain");

                    e.printStackTrace();
                

                @Override
                public void onSuccess(User result) 
                    Window.alert(user.getEmail());

                
            );

    

User 是:

@Entity
public class User implements IsSerializable 

@Id
@Column(name="id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Key id;

private String googleID;

private String firstName;

private String lastName;

private String password;

private String gender;

private String email;


@OneToOne(cascade=CascadeType.ALL)
@JoinColumn(name="key")

private AuthenticationToken token=new AuthenticationToken();

private String pictureStringURL;

private String googlePlusProfileURL;

private String defaultLanguage;

// Lots of Sets and Gets 

方法调用getUser(String googleID)

public User getUser(String googleId)
    EntityManager em = emfInstance.createEntityManager();
    Query q = em
            .createQuery("select  u from User u where u.googleID=:googleId");
    q.setParameter("googleId", googleId);

    return (User) q.getResultList().get(0);

然后我发现我的 Self 在客户端如何无法反序列化密钥中的 Exception

com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException: The response could not be deserialized
    at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:221)
    at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:258)
    at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:412)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
    at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
    at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
    at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:338)
    at com.google.gwt.dev.shell.BrowserChannelServer.invokejavascript(BrowserChannelServer.java:219)
    at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:571)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:279)
    at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
    at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
    at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:242)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
    at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
    at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
    at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:293)
    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547)
    at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
    at java.lang.Thread.run(Thread.java:662)
Caused by: com.google.gwt.user.client.rpc.SerializationException: com.google.appengine.api.datastore.Key/194261103
    at com.google.gwt.user.client.rpc.impl.SerializerBase.getTypeHandler(SerializerBase.java:153)
    at com.google.gwt.user.client.rpc.impl.SerializerBase.instantiate(SerializerBase.java:114)
    at com.google.gwt.user.client.rpc.impl.ClientSerializationStreamReader.deserialize(ClientSerializationStreamReader.java:396)
    at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamReader.readObject(AbstractSerializationStreamReader.java:119)
    at com.cbd.shared.entities.User_FieldSerializer.deserialize(User_FieldSerializer.java:117)
    at com.cbd.shared.entities.User_FieldSerializer.deserial(User_FieldSerializer.java:150)
    at com.google.gwt.user.client.rpc.impl.SerializerBase.deserialize(SerializerBase.java:95)
    at com.google.gwt.user.client.rpc.impl.ClientSerializationStreamReader.deserialize(ClientSerializationStreamReader.java:398)
    at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamReader.readObject(AbstractSerializationStreamReader.java:119)
    at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter$ResponseReader$8.read(RequestCallbackAdapter.java:106)
    at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:214)
    ... 28 more

任何帮助,在此先感谢 :)

【问题讨论】:

【参考方案1】:

尝试将custom GWT serialization 用于您的User 课程。

更新:

您可以尝试对Key:GWT with JDO problem进行字符串编码

【讨论】:

也可以看看这个:fredsa.allen-sauer.com/2009/04/… 无法使用 CustomSerializtion 但字符串工作正常。我以前使用过字符串,但每次我使用它时我都忽略了写@Extension 注释我认为这是额外的,如果你能告诉我它的工作是什么,我会很优雅 顺便说一句:如果它是一个拥有的实体,你只需要一个 Key。如果它是***实体(不属于其他类),那么您可以使用 Long 的 ID。

以上是关于SerializationException while desalinization com.google.appengine.api.datastore.Key GWT的主要内容,如果未能解决你的问题,请参考以下文章

GWT - 偶尔出现 com.google.gwt.user.client.rpc.SerializationException

kotlinx.serialization.SerializationException:找不到类“MultiPartFormDataContent”的序列化程序

使用谓词列表时出现 DataContract SerializationException

Ktor WebSockets:kotlinx.serialization.SerializationException:找不到类“DefaultClientWebSocketSession”的序列化

服务器端的 GWT 违规检查引发 SerializationException

kotlinx.serialization.SerializationException:找不到类“UnitEntity”(myClassName)的序列化程序