Yugal
Yugal

Reputation: 1665

what will be the reason that control is going to onFailure() in GWT?

public interface LoginService extends RemoteService {
         public static final String SERVICE_URI = "/login";
         public static class Util {
            public static LoginServiceAsync getInstance() {

               LoginServiceAsync instance = (LoginServiceAsync) GWT.create(LoginService.class);
               ServiceDefTarget target = (ServiceDefTarget) instance;
               target.setServiceEntryPoint(GWT.getModuleBaseURL() + SERVICE_URI);
               return instance;
            }
         }
       public boolean userIsValid( Map loginData );
      }

and Entry class is

 public void onModuleLoad() {


      final LoginServiceAsync loginService = ( LoginServiceAsync )GWT.create( LoginService.class );
      ServiceDefTarget endpoint = ( ServiceDefTarget )loginService;
      String moduleRelativeURL = GWT.getModuleBaseURL()+"login";
      endpoint.setServiceEntryPoint( moduleRelativeURL );
      this.setLoginPanel();
      final AsyncCallback callback = new AsyncCallback()
      {

         public void onSuccess( Object result ) {

            // take the result coming from the server
            boolean ok = Boolean.valueOf( result.toString() ).booleanValue();
            if( ok )
            {

               MessageBox.alert( "Success", "Successfully logged in!");
            }
            else
            {

               MessageBox.alert( "Invalid", "Wrong username or password");
            }
         }

         public void onFailure( Throwable caught ) {
            MessageBox.alert( "Error", "Error while logging in" );
         }
      };
      loginButton = new Button( "Login" );
      loginButton.addListener( new ButtonListenerAdapter() {
         public void onClick( Button button, EventObject e ) {
            Map loginData = getUserData( formPanel.getForm() );
            loginService.userIsValid( loginData, callback );
         }
      });
      formPanel.addButton( loginButton );
      loginPanel.setBorder( false );
      loginPanel.setPaddings( 5 );
      loginPanel.add( formPanel );
      RootPanel.get().add( loginPanel );
   }


here is server implementation class

public class LoginServiceImpl extends RemoteServiceServlet implements LoginService {
      public boolean userIsValid( Map loginData )
   {
      boolean accepted = false;
      String name = loginData.get( "userName" ).toString();
      String pswd = loginData.get( "pswd" ).toString();
      if( name.equals( "yugal" ) && pswd.equals( "yugal" ) )
      {

         accepted = true;
      }
      else
      {

            accepted = false;
      }
      return accepted;
   }
}


here is web.xml


         LoginService
         org.arosys.server.LoginServiceImpl
 

 
         LoginService
         /login
 


control is going to onFailure( Throwable caught ) method, why? what is the problem?

Upvotes: 0

Views: 404

Answers (1)

z00bs
z00bs

Reputation: 7498

Without any code of the service implementation and without a stacktrace this is impossible to tell. Could please provide us with some code and the exception that gets thrown?

Here some information on how to handle exceptions.

Upvotes: 0

Related Questions