views:

48

answers:

1

I want to develop my first AppEngine application, that will also use GWT. Since I don't have any experience with GWT and AppEngine, I started with tutorials on GWT site, and after succefully completing Getting Started, I started working on http://code.google.com/webtoolkit/doc/latest/tutorial/appengine.html

But I ran into a problem, and I don't have a clue why :)

I am trying to check if user is logged in, like in "Personalize the application with the User Service" section of tutorial.

But when I run the code itself, I get an error:

Error 404 NOT_FOUND

HTTP ERROR 404

Problem accessing /parkmeweb/login. Reason:

    NOT_FOUND


Powered by Jetty://

And here are my files:

LoginService:

@RemoteServiceRelativePath("login")
public interface LoginService extends RemoteService {
  public LoginInfo login(String requestUri);
}

LoginServiceAsync:

public interface LoginServiceAsync {
  public void login(String requestUri, AsyncCallback<LoginInfo> async);
}

LoginServiceImpl:

public class LoginServiceImpl extends RemoteServiceServlet implements
    LoginService {

public LoginInfo login(String requestUri) {
    UserService userService = UserServiceFactory.getUserService();
    User user = userService.getCurrentUser();
    LoginInfo loginInfo = new LoginInfo();

    if (user != null) {
      loginInfo.setLoggedIn(true);
      loginInfo.setEmailAddress(user.getEmail());
      loginInfo.setNickname(user.getNickname());
      loginInfo.setLogoutUrl(userService.createLogoutURL(requestUri));
    } else {
      loginInfo.setLoggedIn(false);
      loginInfo.setLoginUrl(userService.createLoginURL(requestUri));
    }
    return loginInfo;
  }

}

web.xml:

    <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd"&gt;

<web-app>

  <!-- Servlets -->

  <servlet>
    <servlet-name>loginService</servlet-name>
    <servlet-class>com.parkme.parkmeweb.server.LoginServiceImpl</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>loginService</servlet-name>
    <url-pattern>/parkmeweb/login/</url-pattern>
  </servlet-mapping>

  <!-- Default page to serve -->
  <welcome-file-list>
    <welcome-file>ParkmeWeb.html</welcome-file>
  </welcome-file-list>

</web-app>

All this i getting called from OnModuleLoad:

public void onModuleLoad() {
    LoginServiceAsync loginService = GWT.create(LoginService.class);
    loginService.login(GWT.getHostPageBaseURL(), new AsyncCallback<LoginInfo>() {
      public void onFailure(Throwable error) {
             //this is where error is thrown
          Window.alert(error.getMessage());
      }

      public void onSuccess(LoginInfo result) {
        loginInfo = result;
        if(loginInfo.isLoggedIn()) {
          return;
        } else {
          loadLogin();
        }
      }
    });
}

Just by looking at this, I can't see any problems, and I should probably looking for problems elsewhere, but I would like to hear some ideas what went wrong.

A: 

The handler is for /parkmweweb/login/, but you're visiting /parkmeweb/login - without the trailing slash.

Nick Johnson
No, it's not working with or without trailing slash.
Rabas
I'm not familiar with GWT, but you're defining a function called 'login', and not calling it anywhere. How is login supposed to be called? The handler referred to in the app.yaml has to be a servlet, and the standard servlet methods get called on it to handle requests.
Nick Johnson
All it needed was system reboot... It works fine now, thank you for help...
Rabas