gpt4 book ai didi

java - 无法运行 GWT ServiceAsync

转载 作者:行者123 更新时间:2023-12-02 07:44:19 25 4
gpt4 key购买 nike

我正在尝试创建一个异步回调,以从应用程序引擎中的 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);

}

Costumer.class a JDO in gae

 @PersistenceCapable

公共(public)类 Customer 扩展 User 实现可序列化{

/**
*
*/
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(); 

Edit2:添加了请求的代码和完整的错误。尝试将列表传递给哈希集,但错误仍然存​​在。没有找到任何其他解决方案。

最佳答案

你的接口(interface)是错误的。您应该阅读GWT documentation用于进行 RPC 调用。

假设您不需要该方法的任何参数,您的 TableService 接口(interface)应如下所示。

@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);
}

关于java - 无法运行 GWT ServiceAsync,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11105959/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com