java.lang.RuntimeException:GWT中的延迟绑定错误

时间:2015-02-10 05:05:54

标签: java gwt

我正在关注here的教程。 我试图从我的模块进行RPC调用。但是我收到了这个错误。

java.lang.RuntimeException: Deferred binding failed for 'myPackageName.client.StockPriceService' (did you forget to inherit a required module?)

我的StockPriceService类是:

@RemoteServiceRelativePath("stockPrices")
public interface StockPriceService extends RemoteService{

    StockPrice[] getPrices(String[] symbols) throws DelistedException;
}

StockPriceServiceAsync类是:

public interface StockPriceServiceAsync {

    void getPrices(String[] symbols, AsyncCallback<StockPrice[]> callback); 
}

我的StockPrice课程是:

public class StockPrice implements Serializable{

    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    private String symbol;
    private double price;
    private double change;

    public String getSymbol() {
        return symbol;
    }

    public void setSymbol(String symbol) {
        this.symbol = symbol;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public double getChange() {
        return change;
    }

    public void setChange(double change) {
        this.change = change;
    }

    public double getChangePercent() {
        return 100.0 * this.change / this.price;
    }

    public StockPrice(String symbol, double price, double change) {
        super();
        this.symbol = symbol;
        this.price = price;
        this.change = change;
    }
}

在我的EntryPoint类

中执行以下行时,我总是收到错误
private StockPriceServiceAsync stockPriceSvc = GWT.create(StockPriceService.class);

任何形式的帮助都表示赞赏。

1 个答案:

答案 0 :(得分:1)

StockPrice必须具有零参数构造函数或根本没有构造函数用于默认启动。请检查堆栈跟踪并确认。