我正在尝试创建一个异步背,以从应用程序引擎中的 GAE JDO 数据库中返回包含所有客户的列表。我已经做了一个运行良好的登录类,但只返回一个字符串。现在我正在尝试获取列表,但我有来自以下错误:
18:05:39.219 [ERROR] [prototipov8] subtype
com.google.gwt.resources.client.impl.ExternalTextResourcePrototype.ETRCallback is not default
instantiable (it must have a zero-argument constructor or no constructors at all) and has no
custom serializer. (reached via
com.google.gwt.user.client.rpc.AsyncCallback<java.util.List<pt.sites.shared.model.Customer>>)
和
[ERROR] [prototipov8] - subtype com.google.gwt.user.client.rpc.AsyncCallback<T>
is not instantiable
完全错误:
17:54:07.268 [ERROR] [prototipov8] Unable to load module entry point class pt.info2000.sites.client.old.Main (see associated exception for details)
java.lang.RuntimeException: Deferred binding failed for 'pt.info2000.sites.client.old.TableService' (did you forget to inherit a required module?)
at com.google.gwt.dev.shell.GWTBridgeImpl.create(GWTBridgeImpl.java:53)
at com.google.gwt.core.client.GWT.create(GWT.java:97)
at pt.info2000.sites.client.old.Main.<clinit>(Main.java:30)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.google.gwt.dev.shell.ModuleSpace.loadClassFromSourceName(ModuleSpace.java:654)
at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:363)
at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:525)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
at java.lang.Thread.run(Unknown Source)
Caused by: com.google.gwt.core.ext.UnableToCompleteException: (see previous log entries)
at com.google.gwt.dev.shell.ModuleSpace.rebind(ModuleSpace.java:595)
at com.google.gwt.dev.shell.ModuleSpace.rebindAndCreate(ModuleSpace.java:455)
at com.google.gwt.dev.shell.GWTBridgeImpl.create(GWTBridgeImpl.java:49)
at com.google.gwt.core.client.GWT.create(GWT.java:97)
at pt.info2000.sites.client.old.Main.<clinit>(Main.java:30)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.google.gwt.dev.shell.ModuleSpace.loadClassFromSourceName(ModuleSpace.java:654)
at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:363)
at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:525)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
at java.lang.Thread.run(Unknown Source)
电话会议
public static final TableServiceAsync table = GWT.create(TableService.class);
表服务
@RemoteServiceRelativePath("getObjects")
public interface TableService extends RemoteService {
List<Customer> getObjects(AsyncCallback<List<Customer>> callback);
}
表服务异步
public interface TableServiceAsync {
void getObjects(AsyncCallback<List<Customer>> callback,
AsyncCallback<List<Customer>> asyncCallback);
}
服装师.class一个 JDO 在 gae 中
@PersistenceCapable
公共类 客户扩展 用户实现 可序列化 {
/**
*
*/
private static final long serialVersionUID = 1L;
@Persistent
private Date birthDate;
@Persistent
private int nib;
@Persistent
public Set<Key> companies;
@Persistent
public Set<Key> sugestions;
@Persistent
public Set<Key> documents;
/**
* @param code
* @param name
* @param description
* @param creationDate
* @param modificationDate
* @param creator
* @param lastModifier
* @param username
* @param password
* @param avatar
* @param activo
* @param cookie
* @param loginIP
* @param roles
* @param contacts
*/
public Customer(int code, String name, String description,
Date creationDate, Date modificationDate, Key creator,
Key lastModifier, String username, String password, Blob avatar,
boolean activo, String cookie, String loginIP, Set<Key> roles,
Set<Key> contacts) {
super(code, name, description, creationDate, modificationDate, creator,
lastModifier, username, password, avatar, activo, cookie, loginIP,
roles, contacts);
}
public Customer() {
}
我已经尝试找到解决方案,但无法使其工作,有没有人遇到此错误?有什么建议或解决方案吗?提前感谢您花时间阅读本文。任何可以帮助的代码请询问。
Edit1:我有一个没有参数的默认构造函数,该类实现了可序列化的,我可以序列化它。此代码适用于 Customer 类;
Serializable c = new Customer();
编辑2:添加了请求的代码和完整错误。已尝试将列表传递到哈希集,但错误仍然存在。没有找到任何其他解决方案。
你的接口是错误的。应阅读有关进行 RPC 调用的 GWT 文档。
您的 TableService 接口应如下所示,假设您不需要该方法的任何参数。
@RemoteServiceRelativePath("getObjects")
public interface TableService extends RemoteService {
List<Customer> getObjects();
}
然后,您的 TableServiceAsync 将如下所示
public interface TableServiceAsync {
void getObjects(AsyncCallback <List<Customer>> callback);
}
AsyncCallback 不可序列化,这就是您出现此错误的原因。如果您需要将参数传递给您的方法,例如一个字符串数组来标识要获得哪些客户,您的接口将如下所示
@RemoteServiceRelativePath("getObjects")
public interface TableService extends RemoteService {
List<Customer> getObjects(String[] ids);
}
public interface TableServiceAsync {
void getObjects(String[] ids, AsyncCallback <List<Customer>> callback);
}
为了Serializable
一个对象,它需要一个没有参数的默认构造函数。这就是这个错误所说的。仅当对象是可序列化的时,才能将对象从客户端传递到服务器端(反之亦然)。