tags:

views:

619

answers:

1

Hello,

I'm working on a GWT project and have several void remote services that seem to execute just fine, but on the client side, end up firing the onFailure() method. No exceptions are thrown anywhere, and the expected behavior is observed on the backend. I have no idea what could be going wrong. Here is the relevant code:

Interfaces and implementation...

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

Calling code...

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

      });
     }
    }

I know I'm a jerk for posting like 500 lines of code but I've been staring at this since yesterday and can't figure out where I'm going wrong. Maybe a 2nd set of eyes would help...

Thanks, brian

A: 

LGTM I'm afraid.

Are you using the hosted mode or a full-fledged browser? You can try switching and see if it helps.

Also, it might help listening to that //TODO and perform a GWT.log when onFailure is invoked.

Robert Munteanu