0
我有一個RPC呼叫:SerializationException而脫鹽com.google.appengine.api.datastore.Key GWT
@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);
}
然後我發現我的自我面臨這個Exception
在密鑰不能deserializ編輯在客戶端
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
任何幫助,感謝提前:)
還檢查了這一點:http://fredsa.allen-sauer.com/2009/04/1st-look- at-app-engine-using-jdo.html –
無法使用CustomSerializtion,但字符串工作正常。我之前使用過字符串,但每次使用它的時候,我忽略寫@Extension註解我認爲這是額外的,如果你能告訴我它的工作是什麼,我將會很優雅 – YouYou
另一方面:只需要一個Key是一個擁有的實體。如果它是頂級實體(不屬於另一個類),則可以使用Long的ID。 – Deanna