GWT Void远程服务因为看似没有理由而失败

时间:2009-05-29 19:56:33

标签: gwt gwt-rpc

我正在开发一个GWT项目并且有几个似乎执行得很好的无效远程服务,但在客户端,最终会触发onFailure()方法。在任何地方都不会抛出异常,并且在后端会观察到预期的行为。我不知道会出现什么问题。以下是相关代码:

接口和实施......

@RemoteServiceRelativePath("DeleteSearchService")
public interface DeleteSearchService extends RemoteService {
    /**
     * Utility class for simplifying access to the instance of async service.
     */
    public static class Util {
        private static DeleteSearchServiceAsync instance;
        public static DeleteSearchServiceAsync getInstance(){
            if (instance == null) {
                instance = GWT.create(DeleteSearchService.class);
            }
            return instance;
        }
    }

    public void delete(SearchBean search);
}

public interface DeleteSearchServiceAsync {
    public void delete(SearchBean bean, AsyncCallback<Void> callback);
}

public class DeleteSearchServiceImpl extends RemoteServiceServlet implements DeleteSearchService {

    private static final long serialVersionUID = 1L;

    @Override
    public void delete(SearchBean search) {
        try {

            Connection conn = SQLAccess.getConnection();
            String sql = "DELETE FROM `searches` WHERE `id`=?";

            PreparedStatement ps = conn.prepareStatement(sql);
            ps.setInt(1, search.getSearchId());

            ps.execute();

            sql = "DELETE FROM `searchsourcemap` WHERE `search-id` = ?";

            ps = conn.prepareStatement(sql);
            ps.setInt(1, search.getSearchId());

            ps.execute();

            return;

        } catch (Exception e) {
            // TODO Log error
            e.printStackTrace();
        }
    }
}

致电代码......

private class DeleteListener implements ClickListener {
        public void onClick(Widget sender) {
            DeleteSearchServiceAsync dss = DeleteSearchService.Util.getInstance();

            SearchBean bean = buildBeanFromGUI();

            dss.delete(bean, new AsyncCallback<Void>(){

                //@Override
                public void onFailure(Throwable caught) {
                    // TODO log
                    SearchNotDeleted snd = new SearchNotDeleted();
                    snd.show();
                }

                //@Override
                public void onSuccess(Void result) {
                    SearchDeleted sd = new SearchDeleted();
                    sd.show();
                    searchDef.getParent().removeFromParent();                   
                }

            });
        }
    }

我知道我是张贴500行代码的混蛋,但我从昨天起就一直盯着这个,无法弄清楚我哪里出错了。也许第二组眼睛会帮助......

谢谢, 布赖恩

1 个答案:

答案 0 :(得分:0)

LGTM我很害怕。

您使用的是托管模式还是成熟的浏览器?您可以尝试切换,看看它是否有帮助。

此外,在调用//TODO时,可能有助于收听GWT.log并执行onFailure